|
Daniel P. Berrange |
e3a592 |
From 3534cd47a57ee9cf7041472511444784f14d6939 Mon Sep 17 00:00:00 2001
|
|
Daniel P. Berrange |
e3a592 |
From: Daniel P. Berrange <berrange@redhat.com>
|
|
Daniel P. Berrange |
e3a592 |
Date: Mon, 14 Jun 2010 16:08:55 +0100
|
|
Daniel P. Berrange |
e3a592 |
Subject: [PATCH 09/11] Add ability to set a default driver name/type when parsing disks
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
Record a default driver name/type in capabilities struct. Use this
|
|
Daniel P. Berrange |
e3a592 |
when parsing disks if value is not set in XML config.
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
* src/conf/capabilities.h: Record default driver name/type for disks
|
|
Daniel P. Berrange |
e3a592 |
* src/conf/domain_conf.c: Fallback to default driver name/type
|
|
Daniel P. Berrange |
e3a592 |
when parsing disks
|
|
Daniel P. Berrange |
e3a592 |
* src/qemu/qemu_driver.c: Set default driver name/type to raw
|
|
Daniel P. Berrange |
e3a592 |
---
|
|
Daniel P. Berrange |
e3a592 |
src/conf/capabilities.h | 2 ++
|
|
Daniel P. Berrange |
e3a592 |
src/conf/domain_conf.c | 16 +++++++++++++++-
|
|
Daniel P. Berrange |
e3a592 |
src/qemu/qemu_driver.c | 8 ++++++++
|
|
Daniel P. Berrange |
e3a592 |
3 files changed, 25 insertions(+), 1 deletions(-)
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
|
|
Daniel P. Berrange |
e3a592 |
index 9290c82..f676eb8 100644
|
|
Daniel P. Berrange |
e3a592 |
--- a/src/conf/capabilities.h
|
|
Daniel P. Berrange |
e3a592 |
+++ b/src/conf/capabilities.h
|
|
Daniel P. Berrange |
e3a592 |
@@ -123,6 +123,8 @@ struct _virCaps {
|
|
Daniel P. Berrange |
e3a592 |
virCapsGuestPtr *guests;
|
|
Daniel P. Berrange |
e3a592 |
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
|
Daniel P. Berrange |
e3a592 |
unsigned int emulatorRequired : 1;
|
|
Daniel P. Berrange |
e3a592 |
+ const char *defaultDiskDriverName;
|
|
Daniel P. Berrange |
e3a592 |
+ const char *defaultDiskDriverType;
|
|
Daniel P. Berrange |
e3a592 |
void *(*privateDataAllocFunc)(void);
|
|
Daniel P. Berrange |
e3a592 |
void (*privateDataFreeFunc)(void *);
|
|
Daniel P. Berrange |
e3a592 |
int (*privateDataXMLFormat)(virBufferPtr, void *);
|
|
Daniel P. Berrange |
e3a592 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
Daniel P. Berrange |
e3a592 |
index b20ca97..f3b8cfa 100644
|
|
Daniel P. Berrange |
e3a592 |
--- a/src/conf/domain_conf.c
|
|
Daniel P. Berrange |
e3a592 |
+++ b/src/conf/domain_conf.c
|
|
Daniel P. Berrange |
e3a592 |
@@ -1639,6 +1639,16 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
|
Daniel P. Berrange |
e3a592 |
def->serial = serial;
|
|
Daniel P. Berrange |
e3a592 |
serial = NULL;
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
+ if (!def->driverType &&
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverType &&
|
|
Daniel P. Berrange |
e3a592 |
+ !(def->driverType = strdup(caps->defaultDiskDriverType)))
|
|
Daniel P. Berrange |
e3a592 |
+ goto no_memory;
|
|
Daniel P. Berrange |
e3a592 |
+
|
|
Daniel P. Berrange |
e3a592 |
+ if (!def->driverName &&
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverName &&
|
|
Daniel P. Berrange |
e3a592 |
+ !(def->driverName = strdup(caps->defaultDiskDriverName)))
|
|
Daniel P. Berrange |
e3a592 |
+ goto no_memory;
|
|
Daniel P. Berrange |
e3a592 |
+
|
|
Daniel P. Berrange |
e3a592 |
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
|
|
Daniel P. Berrange |
e3a592 |
&& virDomainDiskDefAssignAddress(caps, def) < 0)
|
|
Daniel P. Berrange |
e3a592 |
goto error;
|
|
Daniel P. Berrange |
e3a592 |
@@ -1659,6 +1669,9 @@ cleanup:
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
return def;
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
+no_memory:
|
|
Daniel P. Berrange |
e3a592 |
+ virReportOOMError();
|
|
Daniel P. Berrange |
e3a592 |
+
|
|
Daniel P. Berrange |
e3a592 |
error:
|
|
Daniel P. Berrange |
e3a592 |
virDomainDiskDefFree(def);
|
|
Daniel P. Berrange |
e3a592 |
def = NULL;
|
|
Daniel P. Berrange |
e3a592 |
@@ -4275,7 +4288,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|
Daniel P. Berrange |
e3a592 |
if (n && VIR_ALLOC_N(def->disks, n) < 0)
|
|
Daniel P. Berrange |
e3a592 |
goto no_memory;
|
|
Daniel P. Berrange |
e3a592 |
for (i = 0 ; i < n ; i++) {
|
|
Daniel P. Berrange |
e3a592 |
- virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, nodes[i],
|
|
Daniel P. Berrange |
e3a592 |
+ virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps,
|
|
Daniel P. Berrange |
e3a592 |
+ nodes[i],
|
|
Daniel P. Berrange |
e3a592 |
flags);
|
|
Daniel P. Berrange |
e3a592 |
if (!disk)
|
|
Daniel P. Berrange |
e3a592 |
goto error;
|
|
Daniel P. Berrange |
e3a592 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
Daniel P. Berrange |
e3a592 |
index 3c479c5..14b790e 100644
|
|
Daniel P. Berrange |
e3a592 |
--- a/src/qemu/qemu_driver.c
|
|
Daniel P. Berrange |
e3a592 |
+++ b/src/qemu/qemu_driver.c
|
|
Daniel P. Berrange |
e3a592 |
@@ -1357,6 +1357,14 @@ qemuCreateCapabilities(virCapsPtr oldcaps,
|
|
Daniel P. Berrange |
e3a592 |
return NULL;
|
|
Daniel P. Berrange |
e3a592 |
}
|
|
Daniel P. Berrange |
e3a592 |
|
|
Daniel P. Berrange |
e3a592 |
+ if (driver->allowDiskFormatProbing) {
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverName = NULL;
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverType = NULL;
|
|
Daniel P. Berrange |
e3a592 |
+ } else {
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverName = "qemu";
|
|
Daniel P. Berrange |
e3a592 |
+ caps->defaultDiskDriverType = "raw";
|
|
Daniel P. Berrange |
e3a592 |
+ }
|
|
Daniel P. Berrange |
e3a592 |
+
|
|
Daniel P. Berrange |
e3a592 |
/* Domain XML parser hooks */
|
|
Daniel P. Berrange |
e3a592 |
caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
|
|
Daniel P. Berrange |
e3a592 |
caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
|
|
Daniel P. Berrange |
e3a592 |
--
|
|
Daniel P. Berrange |
e3a592 |
1.7.1.1
|
|
Daniel P. Berrange |
e3a592 |
|