[PATCH 6/6] ch_process: Check whether domain is already running before starting it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/ch/ch_process.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c
index 6d9a286e8a..00d94ddcbe 100644
--- a/src/ch/ch_process.c
+++ b/src/ch/ch_process.c
@@ -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))) {
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux