diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 4478d85f40095ba44d23f73d20c6cc4ae0eccf13..36f97b9b3f6638ac2febb4ba3ec79422676eba8d 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -175,6 +175,9 @@ virCapabilitiesFree(virCapsPtr caps) { VIR_FREE(caps->host.secModel.doi); virCPUDefFree(caps->host.cpu); + VIR_FREE(caps->defaultDiskDriverName); + VIR_FREE(caps->defaultDiskDriverType); + VIR_FREE(caps); } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 9290c826dab0c15b42a322b74f3e01a879d3debc..f676eb8014ca8fa034f362815113d4b8b1d356d0 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -123,6 +123,8 @@ struct _virCaps { virCapsGuestPtr *guests; unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; unsigned int emulatorRequired : 1; + const char *defaultDiskDriverName; + const char *defaultDiskDriverType; void *(*privateDataAllocFunc)(void); void (*privateDataFreeFunc)(void *); int (*privateDataXMLFormat)(virBufferPtr, void *); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b20ca975e5c1ff5074f3f3989837ded5d1008c77..f3b8cfa3a56b0b8ac539e2669002495bcd1b76d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1639,6 +1639,16 @@ virDomainDiskDefParseXML(virCapsPtr caps, def->serial = serial; serial = NULL; + if (!def->driverType && + caps->defaultDiskDriverType && + !(def->driverType = strdup(caps->defaultDiskDriverType))) + goto no_memory; + + if (!def->driverName && + caps->defaultDiskDriverName && + !(def->driverName = strdup(caps->defaultDiskDriverName))) + goto no_memory; + if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && virDomainDiskDefAssignAddress(caps, def) < 0) goto error; @@ -1659,6 +1669,9 @@ cleanup: return def; +no_memory: + virReportOOMError(); + error: virDomainDiskDefFree(def); def = NULL; @@ -4275,7 +4288,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (n && VIR_ALLOC_N(def->disks, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, nodes[i], + virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, + nodes[i], flags); if (!disk) goto error; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ca87ca80a40fce0619acac9f2e6f19c8f107a72d..2eb254e7d1365f471e8cc49b078222a5cd473456 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1361,6 +1361,14 @@ qemuCreateCapabilities(virCapsPtr oldcaps, return NULL; } + if (driver->allowDiskFormatProbing) { + caps->defaultDiskDriverName = NULL; + caps->defaultDiskDriverType = NULL; + } else { + caps->defaultDiskDriverName = "qemu"; + caps->defaultDiskDriverType = "raw"; + } + /* Domain XML parser hooks */ caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc; caps->privateDataFreeFunc = qemuDomainObjPrivateFree;