render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 0ebc2077b69700849c366dd644911f47503bfbaa Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <0ebc2077b69700849c366dd644911f47503bfbaa.1377873637.git.jdenemar@redhat.com>
43fe83
From: Guannan Ren <gren@redhat.com>
43fe83
Date: Thu, 8 Aug 2013 16:07:28 +0800
43fe83
Subject: [PATCH] qemu: check presence of each disk and its backing file as
43fe83
 well
43fe83
43fe83
Resovles: https://bugzilla.redhat.com/show_bug.cgi?id=910171
43fe83
(cherry picked from commit dbca8414577a0d76a5bad9eb5919130db7bc451f)
43fe83
43fe83
For disk with startupPolicy support, such as cdrom and floppy
43fe83
when its chain is broken, the startup policy will apply,
43fe83
otherwise, report an error.
43fe83
---
43fe83
 src/qemu/qemu_domain.c  | 33 +++++++++++++--------------------
43fe83
 src/qemu/qemu_process.c |  6 ------
43fe83
 2 files changed, 13 insertions(+), 26 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
43fe83
index fd62deb..d0f09ae 100644
43fe83
--- a/src/qemu/qemu_domain.c
43fe83
+++ b/src/qemu/qemu_domain.c
43fe83
@@ -2084,19 +2084,11 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
43fe83
             break;
43fe83
 
43fe83
         case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
43fe83
-            virReportSystemError(errno,
43fe83
-                                 _("cannot access file '%s'"),
43fe83
-                                 disk->src);
43fe83
             goto error;
43fe83
-            break;
43fe83
 
43fe83
         case VIR_DOMAIN_STARTUP_POLICY_REQUISITE:
43fe83
-            if (cold_boot) {
43fe83
-                virReportSystemError(errno,
43fe83
-                                     _("cannot access file '%s'"),
43fe83
-                                     disk->src);
43fe83
+            if (cold_boot)
43fe83
                 goto error;
43fe83
-            }
43fe83
             break;
43fe83
 
43fe83
         case VIR_DOMAIN_STARTUP_POLICY_DEFAULT:
43fe83
@@ -2105,6 +2097,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
43fe83
             break;
43fe83
     }
43fe83
 
43fe83
+    virResetLastError();
43fe83
     VIR_DEBUG("Dropping disk '%s' on domain '%s' (UUID '%s') "
43fe83
               "due to inaccessible source '%s'",
43fe83
               disk->dst, vm->def->name, uuid, disk->src);
43fe83
@@ -2130,30 +2123,30 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
43fe83
     int ret = -1;
43fe83
     size_t i;
43fe83
     virDomainDiskDefPtr disk;
43fe83
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
43fe83
 
43fe83
+    VIR_DEBUG("Checking for disk presence");
43fe83
     for (i = 0; i < vm->def->ndisks; i++) {
43fe83
         disk = vm->def->disks[i];
43fe83
 
43fe83
-        if (!disk->startupPolicy || !disk->src)
43fe83
+        if (!disk->src)
43fe83
             continue;
43fe83
 
43fe83
-        if (virFileAccessibleAs(disk->src, F_OK,
43fe83
-                                cfg->user,
43fe83
-                                cfg->group) >= 0) {
43fe83
-            /* disk accessible */
43fe83
+        if (qemuDomainDetermineDiskChain(driver, disk, false) >= 0 &&
43fe83
+            qemuDiskChainCheckBroken(disk) >= 0)
43fe83
             continue;
43fe83
+
43fe83
+        if (disk->startupPolicy) {
43fe83
+            if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
43fe83
+                                                 cold_boot) >= 0)
43fe83
+                continue;
43fe83
         }
43fe83
 
43fe83
-        if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
43fe83
-                                             cold_boot) < 0)
43fe83
-            goto cleanup;
43fe83
+        goto error;
43fe83
     }
43fe83
 
43fe83
     ret = 0;
43fe83
 
43fe83
-cleanup:
43fe83
-    virObjectUnref(cfg);
43fe83
+error:
43fe83
     return ret;
43fe83
 }
43fe83
 
43fe83
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
43fe83
index d631a6f..0dccac3 100644
43fe83
--- a/src/qemu/qemu_process.c
43fe83
+++ b/src/qemu/qemu_process.c
43fe83
@@ -3621,16 +3621,10 @@ int qemuProcessStart(virConnectPtr conn,
43fe83
     if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
43fe83
         goto cleanup;
43fe83
 
43fe83
-    VIR_DEBUG("Checking for CDROM and floppy presence");
43fe83
     if (qemuDomainCheckDiskPresence(driver, vm,
43fe83
                                     flags & VIR_QEMU_PROCESS_START_COLD) < 0)
43fe83
         goto cleanup;
43fe83
 
43fe83
-    for (i = 0; i < vm->def->ndisks; i++) {
43fe83
-        if (qemuDomainDetermineDiskChain(driver, vm->def->disks[i],
43fe83
-                                         false) < 0)
43fe83
-            goto cleanup;
43fe83
-    }
43fe83
 
43fe83
     /* Get the advisory nodeset from numad if 'placement' of
43fe83
      * either <vcpu> or <numatune> is 'auto'.
43fe83
-- 
43fe83
1.8.3.2
43fe83