mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-01 20:05:19 +00:00
conf: Introduce virDomainLoaderDefNew()
For now we just allocate the object, so the only advantage is that invocations are shorter and look a bit nicer. Later on, its introduction will pay off by letting us change things in a single spot instead of all over the library. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c6bff86ae1
commit
572ab7cb76
@ -78,7 +78,7 @@ bhyveFirmwareFillDomain(bhyveConn *driver,
|
||||
}
|
||||
|
||||
if (!def->os.loader)
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||
|
@ -3723,6 +3723,12 @@ virDomainPanicDefFree(virDomainPanicDef *panic)
|
||||
g_free(panic);
|
||||
}
|
||||
|
||||
virDomainLoaderDef *
|
||||
virDomainLoaderDefNew(void)
|
||||
{
|
||||
return g_new0(virDomainLoaderDef, 1);
|
||||
}
|
||||
|
||||
void
|
||||
virDomainLoaderDefFree(virDomainLoaderDef *loader)
|
||||
{
|
||||
@ -17245,7 +17251,7 @@ virDomainDefParseBootLoaderOptions(virDomainDef *def,
|
||||
if (!loaderNode && !nvramNode)
|
||||
return 0;
|
||||
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
if (virDomainLoaderDefParseXML(def->os.loader,
|
||||
loaderNode, nvramNode, nvramSourceNode,
|
||||
|
@ -2316,6 +2316,7 @@ struct _virDomainLoaderDef {
|
||||
char *nvramTemplate; /* user override of path to master nvram */
|
||||
};
|
||||
|
||||
virDomainLoaderDef *virDomainLoaderDefNew(void);
|
||||
void virDomainLoaderDefFree(virDomainLoaderDef *loader);
|
||||
|
||||
typedef enum {
|
||||
|
@ -507,6 +507,7 @@ virDomainLeaseRemoveAt;
|
||||
virDomainLifecycleActionTypeFromString;
|
||||
virDomainLifecycleActionTypeToString;
|
||||
virDomainLoaderDefFree;
|
||||
virDomainLoaderDefNew;
|
||||
virDomainLoaderTypeFromString;
|
||||
virDomainLoaderTypeToString;
|
||||
virDomainLockFailureTypeFromString;
|
||||
|
@ -643,7 +643,7 @@ libxlMakeDomBuildInfo(virDomainDef *def,
|
||||
*/
|
||||
if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI) {
|
||||
if (def->os.loader == NULL)
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
if (def->os.loader->path == NULL)
|
||||
def->os.loader->path = g_strdup(cfg->firmwares[0]->name);
|
||||
if (def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_NONE)
|
||||
|
@ -111,7 +111,7 @@ xenParseXLOS(virConf *conf, virDomainDef *def, virCaps *caps)
|
||||
return -1;
|
||||
|
||||
if (bios && STREQ(bios, "ovmf")) {
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||
|
||||
@ -120,7 +120,7 @@ xenParseXLOS(virConf *conf, virDomainDef *def, virCaps *caps)
|
||||
for (i = 0; i < caps->nguests; i++) {
|
||||
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
|
||||
caps->guests[i]->arch.id == def->os.arch) {
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
def->os.loader->path = g_strdup(caps->guests[i]->arch.defaultInfo.loader);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ xenParseXMOS(virConf *conf, virDomainDef *def)
|
||||
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||
g_autofree char *boot = NULL;
|
||||
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
if (xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0)
|
||||
return -1;
|
||||
|
@ -1168,7 +1168,7 @@ qemuFirmwareEnableFeatures(virQEMUDriver *driver,
|
||||
switch (fw->mapping.device) {
|
||||
case QEMU_FIRMWARE_DEVICE_FLASH:
|
||||
if (!def->os.loader)
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||
@ -1218,7 +1218,7 @@ qemuFirmwareEnableFeatures(virQEMUDriver *driver,
|
||||
|
||||
case QEMU_FIRMWARE_DEVICE_MEMORY:
|
||||
if (!def->os.loader)
|
||||
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_ROM;
|
||||
def->os.loader->path = g_strdup(memory->filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user