]> xenbits.xensource.com Git - libvirt.git/commitdiff
ch_process: Check whether domain is already running before starting it
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 10 Feb 2022 15:17:20 +0000 (16:17 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Feb 2022 09:48:39 +0000 (10:48 +0100)
There are two places where a domain can be started in CH driver:
chDomainCreateXML() and chDomainCreateWithFlags(). Both acquire a
job (good), but neither of them checks whether the domain isn't
already running. This is wrong. Fortunately, both function call
the very same virCHProcessStart() rendering it the best place for
such check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/ch/ch_process.c

index 6d9a286e8ae23183a37744e503d112dcd8bbb6ae..00d94ddcbeb21bc10b3466d28bf8e8aa76465c96 100644 (file)
@@ -470,6 +470,12 @@ virCHProcessStart(virCHDriver *driver,
     g_autofree int *nicindexes = NULL;
     size_t nnicindexes = 0;
 
+    if (virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("VM is already active"));
+        return -1;
+    }
+
     if (!priv->monitor) {
         /* And we can get the first monitor connection now too */
         if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm))) {