render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 0ebc2077b69700849c366dd644911f47503bfbaa Mon Sep 17 00:00:00 2001
Message-Id: <0ebc2077b69700849c366dd644911f47503bfbaa.1377873637.git.jdenemar@redhat.com>
From: Guannan Ren <gren@redhat.com>
Date: Thu, 8 Aug 2013 16:07:28 +0800
Subject: [PATCH] qemu: check presence of each disk and its backing file as
 well

Resovles: https://bugzilla.redhat.com/show_bug.cgi?id=910171
(cherry picked from commit dbca8414577a0d76a5bad9eb5919130db7bc451f)

For disk with startupPolicy support, such as cdrom and floppy
when its chain is broken, the startup policy will apply,
otherwise, report an error.
---
 src/qemu/qemu_domain.c  | 33 +++++++++++++--------------------
 src/qemu/qemu_process.c |  6 ------
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fd62deb..d0f09ae 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2084,19 +2084,11 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
             break;
 
         case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
-            virReportSystemError(errno,
-                                 _("cannot access file '%s'"),
-                                 disk->src);
             goto error;
-            break;
 
         case VIR_DOMAIN_STARTUP_POLICY_REQUISITE:
-            if (cold_boot) {
-                virReportSystemError(errno,
-                                     _("cannot access file '%s'"),
-                                     disk->src);
+            if (cold_boot)
                 goto error;
-            }
             break;
 
         case VIR_DOMAIN_STARTUP_POLICY_DEFAULT:
@@ -2105,6 +2097,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
             break;
     }
 
+    virResetLastError();
     VIR_DEBUG("Dropping disk '%s' on domain '%s' (UUID '%s') "
               "due to inaccessible source '%s'",
               disk->dst, vm->def->name, uuid, disk->src);
@@ -2130,30 +2123,30 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
     int ret = -1;
     size_t i;
     virDomainDiskDefPtr disk;
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 
+    VIR_DEBUG("Checking for disk presence");
     for (i = 0; i < vm->def->ndisks; i++) {
         disk = vm->def->disks[i];
 
-        if (!disk->startupPolicy || !disk->src)
+        if (!disk->src)
             continue;
 
-        if (virFileAccessibleAs(disk->src, F_OK,
-                                cfg->user,
-                                cfg->group) >= 0) {
-            /* disk accessible */
+        if (qemuDomainDetermineDiskChain(driver, disk, false) >= 0 &&
+            qemuDiskChainCheckBroken(disk) >= 0)
             continue;
+
+        if (disk->startupPolicy) {
+            if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
+                                                 cold_boot) >= 0)
+                continue;
         }
 
-        if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
-                                             cold_boot) < 0)
-            goto cleanup;
+        goto error;
     }
 
     ret = 0;
 
-cleanup:
-    virObjectUnref(cfg);
+error:
     return ret;
 }
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d631a6f..0dccac3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3621,16 +3621,10 @@ int qemuProcessStart(virConnectPtr conn,
     if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
         goto cleanup;
 
-    VIR_DEBUG("Checking for CDROM and floppy presence");
     if (qemuDomainCheckDiskPresence(driver, vm,
                                     flags & VIR_QEMU_PROCESS_START_COLD) < 0)
         goto cleanup;
 
-    for (i = 0; i < vm->def->ndisks; i++) {
-        if (qemuDomainDetermineDiskChain(driver, vm->def->disks[i],
-                                         false) < 0)
-            goto cleanup;
-    }
 
     /* Get the advisory nodeset from numad if 'placement' of
      * either <vcpu> or <numatune> is 'auto'.
-- 
1.8.3.2