提交 03ca4204 编写于 作者: D Daniel P. Berrange

Add ability to set a default driver name/type when parsing disks

Record a default driver name/type in capabilities struct. Use this
when parsing disks if value is not set in XML config.

* src/conf/capabilities.h: Record default driver name/type for disks
* src/conf/domain_conf.c: Fallback to default driver name/type
  when parsing disks
* src/qemu/qemu_driver.c: Set default driver name/type to raw
上级 68719c4b
...@@ -175,6 +175,9 @@ virCapabilitiesFree(virCapsPtr caps) { ...@@ -175,6 +175,9 @@ virCapabilitiesFree(virCapsPtr caps) {
VIR_FREE(caps->host.secModel.doi); VIR_FREE(caps->host.secModel.doi);
virCPUDefFree(caps->host.cpu); virCPUDefFree(caps->host.cpu);
VIR_FREE(caps->defaultDiskDriverName);
VIR_FREE(caps->defaultDiskDriverType);
VIR_FREE(caps); VIR_FREE(caps);
} }
......
...@@ -123,6 +123,8 @@ struct _virCaps { ...@@ -123,6 +123,8 @@ struct _virCaps {
virCapsGuestPtr *guests; virCapsGuestPtr *guests;
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
unsigned int emulatorRequired : 1; unsigned int emulatorRequired : 1;
const char *defaultDiskDriverName;
const char *defaultDiskDriverType;
void *(*privateDataAllocFunc)(void); void *(*privateDataAllocFunc)(void);
void (*privateDataFreeFunc)(void *); void (*privateDataFreeFunc)(void *);
int (*privateDataXMLFormat)(virBufferPtr, void *); int (*privateDataXMLFormat)(virBufferPtr, void *);
......
...@@ -1639,6 +1639,16 @@ virDomainDiskDefParseXML(virCapsPtr caps, ...@@ -1639,6 +1639,16 @@ virDomainDiskDefParseXML(virCapsPtr caps,
def->serial = serial; def->serial = serial;
serial = NULL; 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 if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
&& virDomainDiskDefAssignAddress(caps, def) < 0) && virDomainDiskDefAssignAddress(caps, def) < 0)
goto error; goto error;
...@@ -1659,6 +1669,9 @@ cleanup: ...@@ -1659,6 +1669,9 @@ cleanup:
return def; return def;
no_memory:
virReportOOMError();
error: error:
virDomainDiskDefFree(def); virDomainDiskDefFree(def);
def = NULL; def = NULL;
...@@ -4275,7 +4288,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, ...@@ -4275,7 +4288,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
if (n && VIR_ALLOC_N(def->disks, n) < 0) if (n && VIR_ALLOC_N(def->disks, n) < 0)
goto no_memory; goto no_memory;
for (i = 0 ; i < n ; i++) { for (i = 0 ; i < n ; i++) {
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, nodes[i], virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps,
nodes[i],
flags); flags);
if (!disk) if (!disk)
goto error; goto error;
......
...@@ -1361,6 +1361,14 @@ qemuCreateCapabilities(virCapsPtr oldcaps, ...@@ -1361,6 +1361,14 @@ qemuCreateCapabilities(virCapsPtr oldcaps,
return NULL; return NULL;
} }
if (driver->allowDiskFormatProbing) {
caps->defaultDiskDriverName = NULL;
caps->defaultDiskDriverType = NULL;
} else {
caps->defaultDiskDriverName = "qemu";
caps->defaultDiskDriverType = "raw";
}
/* Domain XML parser hooks */ /* Domain XML parser hooks */
caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc; caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
caps->privateDataFreeFunc = qemuDomainObjPrivateFree; caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册