mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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:
parent
4750c848e9
commit
9ea249e7d9
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) \
|
||||
|
@ -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) \
|
||||
|
@ -451,7 +451,7 @@ mymain(void)
|
||||
#endif
|
||||
|
||||
if (virThreadInitialize() < 0 ||
|
||||
!(xmlopt = virQEMUDriverCreateXMLConf()))
|
||||
!(xmlopt = virQEMUDriverCreateXMLConf(NULL)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
virEventRegisterDefaultImpl();
|
||||
|
@ -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)
|
||||
|
@ -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) \
|
||||
|
@ -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) {
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user