virCaps: get rid of defaultDiskDriverName

This patch removes the defaultDiskDriverName from the virCaps
structure. This particular default value is used only in the qemu driver
so this patch uses the recently added callback to fill the driver name
if it's needed instead of propagating it through virCaps.
This commit is contained in:
Peter Krempa 2013-03-11 10:24:29 +01:00
parent 4750c848e9
commit 9ea249e7d9
13 changed files with 34 additions and 24 deletions

View File

@ -164,7 +164,6 @@ struct _virCaps {
/* Move to virDomainXMLOption later */
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
unsigned int emulatorRequired : 1;
const char *defaultDiskDriverName;
int defaultDiskDriverType; /* enum virStorageFileFormat */
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
bool hasWideScsiBus;

View File

@ -4829,11 +4829,6 @@ virDomainDiskDefParseXML(virCapsPtr caps,
def->format = caps->defaultDiskDriverType;
}
if (!def->driverName &&
caps->defaultDiskDriverName &&
!(def->driverName = strdup(caps->defaultDiskDriverName)))
goto no_memory;
if (mirrorFormat) {
def->mirrorFormat = virStorageFileFormatTypeFromString(mirrorFormat);
if (def->mirrorFormat <= 0) {
@ -4896,9 +4891,6 @@ cleanup:
ctxt->node = save_ctxt;
return def;
no_memory:
virReportOOMError();
error:
virDomainDiskDefFree(def);
def = NULL;

View File

@ -552,8 +552,9 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
}
virDomainXMLOptionPtr
virQEMUDriverCreateXMLConf(void)
virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
{
virQEMUDriverDomainDefParserConfig.priv = driver;
return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
&virQEMUDriverPrivateDataCallbacks,
&virQEMUDriverDomainXMLNamespace);
@ -574,10 +575,8 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
goto no_memory;
if (cfg->allowDiskFormatProbing) {
caps->defaultDiskDriverName = NULL;
caps->defaultDiskDriverType = VIR_STORAGE_FILE_AUTO;
} else {
caps->defaultDiskDriverName = "qemu";
caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW;
}

View File

@ -301,6 +301,7 @@ void qemuSharedDiskEntryFree(void *payload, const void *name)
ATTRIBUTE_NONNULL(1);
int qemuDriverAllocateID(virQEMUDriverPtr driver);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
#endif /* __QEMUD_CONF_H */

View File

@ -666,19 +666,38 @@ static int
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
void *opaque)
{
int ret = -1;
virQEMUDriverPtr driver = opaque;
virQEMUDriverConfigPtr cfg = NULL;
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
if (!dev->data.net->model &&
!(dev->data.net->model = strdup("rtl8139")))
goto no_memory;
}
return 0;
if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
!dev->data.disk->driverName &&
driver &&
(cfg = virQEMUDriverGetConfig(driver))) {
if (!cfg->allowDiskFormatProbing &&
!(dev->data.disk->driverName = strdup("qemu"))) {
goto no_memory;
}
}
ret = 0;
cleanup:
virObjectUnref(cfg);
return ret;
no_memory:
virReportOOMError();
return -1;
goto cleanup;
}

View File

@ -723,7 +723,7 @@ qemuStartup(bool privileged,
if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL)
goto error;
if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf()))
if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf(qemu_driver)))
goto error;
/* If hugetlbfs is present, then we need to create a sub-directory within

View File

@ -91,7 +91,7 @@ mymain(void)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf()))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
return EXIT_FAILURE;
# define DO_TEST(name, uuid, internal) \

View File

@ -120,7 +120,7 @@ mymain(void)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf()))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
return EXIT_FAILURE;
# define DO_TEST_FULL(name, extraFlags, migrateFrom) \

View File

@ -451,7 +451,7 @@ mymain(void)
#endif
if (virThreadInitialize() < 0 ||
!(xmlopt = virQEMUDriverCreateXMLConf()))
!(xmlopt = virQEMUDriverCreateXMLConf(NULL)))
return EXIT_FAILURE;
virEventRegisterDefaultImpl();

View File

@ -294,7 +294,7 @@ mymain(void)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf()))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
return EXIT_FAILURE;
VIR_FREE(driver.config->stateDir);
if ((driver.config->stateDir = strdup("/nowhere")) == NULL)

View File

@ -106,7 +106,7 @@ mymain(void)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf()))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
return EXIT_FAILURE;
# define DO_TEST_FULL(name, is_different, when) \

View File

@ -204,7 +204,7 @@ mymain(void)
driver.config = virQEMUDriverConfigNew(false);
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf()))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
return EXIT_FAILURE;
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {

View File

@ -328,7 +328,7 @@ mymain(void)
if ((caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(xmlopt = virQEMUDriverCreateXMLConf()))
if (!(xmlopt = virQEMUDriverCreateXMLConf(NULL)))
return EXIT_FAILURE;
#define DO_TEST_LABELING(name) \