|
|
43fe83 |
From e32ede7d892db2b5903039e43bed2d490120625a Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <e32ede7d892db2b5903039e43bed2d490120625a.1377873637.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Guannan Ren <gren@redhat.com>
|
|
|
43fe83 |
Date: Thu, 8 Aug 2013 16:07:26 +0800
|
|
|
43fe83 |
Subject: [PATCH] qemu: refactor qemuDomainCheckDiskPresence for only disk
|
|
|
43fe83 |
presence check
|
|
|
43fe83 |
|
|
|
43fe83 |
Resovles:https://bugzilla.redhat.com/show_bug.cgi?id=910171
|
|
|
43fe83 |
(cherry picked from commit e2ccc96cf0ea53aa6198efdfba79996c360567d7)
|
|
|
43fe83 |
|
|
|
43fe83 |
Refactor this function to make it focus on disk presence checking,
|
|
|
43fe83 |
including diskchain checking, and not only for CDROM and Floppy.
|
|
|
43fe83 |
This change is good for the following patches.
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/qemu/qemu_domain.c | 98 +++++++++++++++++++++++++++++---------------------
|
|
|
43fe83 |
1 file changed, 58 insertions(+), 40 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
43fe83 |
index dc72722..13303da 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_domain.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_domain.c
|
|
|
43fe83 |
@@ -2067,6 +2067,61 @@ cleanup:
|
|
|
43fe83 |
virObjectUnref(cfg);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
+static int
|
|
|
43fe83 |
+qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
|
|
|
43fe83 |
+ virDomainObjPtr vm,
|
|
|
43fe83 |
+ virDomainDiskDefPtr disk,
|
|
|
43fe83 |
+ bool cold_boot)
|
|
|
43fe83 |
+{
|
|
|
43fe83 |
+ char uuid[VIR_UUID_STRING_BUFLEN];
|
|
|
43fe83 |
+ virDomainEventPtr event = NULL;
|
|
|
43fe83 |
+ int startupPolicy = disk->startupPolicy;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ virUUIDFormat(vm->def->uuid, uuid);
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ switch ((enum virDomainStartupPolicy) startupPolicy) {
|
|
|
43fe83 |
+ case VIR_DOMAIN_STARTUP_POLICY_OPTIONAL:
|
|
|
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 |
+ goto error;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ break;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ case VIR_DOMAIN_STARTUP_POLICY_DEFAULT:
|
|
|
43fe83 |
+ case VIR_DOMAIN_STARTUP_POLICY_LAST:
|
|
|
43fe83 |
+ /* this should never happen */
|
|
|
43fe83 |
+ break;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
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 |
+
|
|
|
43fe83 |
+ event = virDomainEventDiskChangeNewFromObj(vm, disk->src, NULL, disk->info.alias,
|
|
|
43fe83 |
+ VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START);
|
|
|
43fe83 |
+ if (event)
|
|
|
43fe83 |
+ qemuDomainEventQueue(driver, event);
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ VIR_FREE(disk->src);
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ return 0;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+error:
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
+}
|
|
|
43fe83 |
+
|
|
|
43fe83 |
int
|
|
|
43fe83 |
qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
|
|
|
43fe83 |
virDomainObjPtr vm,
|
|
|
43fe83 |
@@ -2075,12 +2130,8 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
|
|
|
43fe83 |
int ret = -1;
|
|
|
43fe83 |
size_t i;
|
|
|
43fe83 |
virDomainDiskDefPtr disk;
|
|
|
43fe83 |
- char uuid[VIR_UUID_STRING_BUFLEN];
|
|
|
43fe83 |
- virDomainEventPtr event = NULL;
|
|
|
43fe83 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
43fe83 |
|
|
|
43fe83 |
- virUUIDFormat(vm->def->uuid, uuid);
|
|
|
43fe83 |
-
|
|
|
43fe83 |
for (i = 0; i < vm->def->ndisks; i++) {
|
|
|
43fe83 |
disk = vm->def->disks[i];
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -2094,42 +2145,9 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
|
|
|
43fe83 |
continue;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
- switch ((enum virDomainStartupPolicy) disk->startupPolicy) {
|
|
|
43fe83 |
- case VIR_DOMAIN_STARTUP_POLICY_OPTIONAL:
|
|
|
43fe83 |
- break;
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
|
|
|
43fe83 |
- virReportSystemError(errno,
|
|
|
43fe83 |
- _("cannot access file '%s'"),
|
|
|
43fe83 |
- disk->src);
|
|
|
43fe83 |
- goto cleanup;
|
|
|
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 |
- goto cleanup;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
- break;
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- case VIR_DOMAIN_STARTUP_POLICY_DEFAULT:
|
|
|
43fe83 |
- case VIR_DOMAIN_STARTUP_POLICY_LAST:
|
|
|
43fe83 |
- /* this should never happen */
|
|
|
43fe83 |
- break;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
-
|
|
|
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 |
-
|
|
|
43fe83 |
- event = virDomainEventDiskChangeNewFromObj(vm, disk->src, NULL, disk->info.alias,
|
|
|
43fe83 |
- VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START);
|
|
|
43fe83 |
- if (event)
|
|
|
43fe83 |
- qemuDomainEventQueue(driver, event);
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- VIR_FREE(disk->src);
|
|
|
43fe83 |
+ if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
|
|
|
43fe83 |
+ cold_boot) < 0)
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
ret = 0;
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|