mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
conf: Convert virDomainDefParseBootXML() to virXMLProp*()
After previous cleanups, the virDomainDefParseBootXML() function uses a mixture of virXMLProp*() and the old virXMLPropString() + virXXXTypeFromString() patterns. Rework it so that virXMLProp*() is used. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0aaf410262
commit
0eb42087c7
@ -16905,7 +16905,6 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
|||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
g_autofree char *tmp = NULL;
|
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
|
|
||||||
/* analysis of the boot devices */
|
/* analysis of the boot devices */
|
||||||
@ -16913,20 +16912,13 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < n && i < VIR_DOMAIN_BOOT_LAST; i++) {
|
for (i = 0; i < n && i < VIR_DOMAIN_BOOT_LAST; i++) {
|
||||||
int val;
|
if (virXMLPropEnum(nodes[i], "dev",
|
||||||
g_autofree char *dev = virXMLPropString(nodes[i], "dev");
|
virDomainBootTypeFromString,
|
||||||
if (!dev) {
|
VIR_XML_PROP_REQUIRED,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
&def->os.bootDevs[def->os.nBootDevs]) < 0)
|
||||||
"%s", _("missing boot device"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if ((val = virDomainBootTypeFromString(dev)) < 0) {
|
def->os.nBootDevs++;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown boot device '%s'"),
|
|
||||||
dev);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
def->os.bootDevs[def->os.nBootDevs++] = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((node = virXPathNode("./os/bootmenu[1]", ctxt))) {
|
if ((node = virXPathNode("./os/bootmenu[1]", ctxt))) {
|
||||||
@ -16935,36 +16927,33 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
|||||||
&def->os.bootmenu) < 0)
|
&def->os.bootmenu) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
tmp = virXMLPropString(node, "timeout");
|
if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES) {
|
||||||
if (tmp && def->os.bootmenu == VIR_TRISTATE_BOOL_YES) {
|
int rv;
|
||||||
if (virStrToLong_uip(tmp, NULL, 0, &def->os.bm_timeout) < 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
if ((rv = virXMLPropUInt(node, "timeout", 10,
|
||||||
_("invalid value for boot menu timeout"));
|
VIR_XML_PROP_NONE,
|
||||||
|
&def->os.bm_timeout)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (rv > 0) {
|
||||||
|
def->os.bm_timeout_set = true;
|
||||||
}
|
}
|
||||||
def->os.bm_timeout_set = true;
|
|
||||||
}
|
}
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((node = virXPathNode("./os/bios[1]", ctxt))) {
|
if ((node = virXPathNode("./os/bios[1]", ctxt))) {
|
||||||
tmp = virXMLPropString(node, "useserial");
|
int rv;
|
||||||
if (tmp) {
|
|
||||||
bool state = false;
|
if (virXMLPropTristateBool(node, "useserial",
|
||||||
ignore_value(virStringParseYesNo(tmp, &state));
|
VIR_XML_PROP_NONE,
|
||||||
def->os.bios.useserial = virTristateBoolFromBool(state);
|
&def->os.bios.useserial) < 0) {
|
||||||
VIR_FREE(tmp);
|
def->os.bios.useserial = VIR_TRISTATE_BOOL_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = virXMLPropString(node, "rebootTimeout");
|
if ((rv = virXMLPropInt(node, "rebootTimeout", 10,
|
||||||
if (tmp) {
|
VIR_XML_PROP_NONE,
|
||||||
/* that was really just for the check if it is there */
|
&def->os.bios.rt_delay, 0)) < 0) {
|
||||||
|
return -1;
|
||||||
if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0) {
|
} else if (rv > 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("invalid value for rebootTimeout"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
def->os.bios.rt_set = true;
|
def->os.bios.rt_set = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2195,7 +2195,7 @@ typedef enum {
|
|||||||
VIR_ENUM_DECL(virDomainLockFailure);
|
VIR_ENUM_DECL(virDomainLockFailure);
|
||||||
|
|
||||||
struct _virDomainBIOSDef {
|
struct _virDomainBIOSDef {
|
||||||
int useserial; /* enum virTristateBool */
|
virTristateBool useserial;
|
||||||
/* reboot-timeout parameters */
|
/* reboot-timeout parameters */
|
||||||
bool rt_set;
|
bool rt_set;
|
||||||
int rt_delay;
|
int rt_delay;
|
||||||
@ -2324,7 +2324,7 @@ struct _virDomainOSDef {
|
|||||||
virArch arch;
|
virArch arch;
|
||||||
char *machine;
|
char *machine;
|
||||||
size_t nBootDevs;
|
size_t nBootDevs;
|
||||||
int bootDevs[VIR_DOMAIN_BOOT_LAST];
|
virDomainBootOrder bootDevs[VIR_DOMAIN_BOOT_LAST];
|
||||||
virTristateBool bootmenu;
|
virTristateBool bootmenu;
|
||||||
unsigned int bm_timeout;
|
unsigned int bm_timeout;
|
||||||
bool bm_timeout_set;
|
bool bm_timeout_set;
|
||||||
|
@ -609,6 +609,8 @@ libxlMakeDomBuildInfo(virDomainDef *def,
|
|||||||
case VIR_DOMAIN_BOOT_NET:
|
case VIR_DOMAIN_BOOT_NET:
|
||||||
bootorder[i] = 'n';
|
bootorder[i] = 'n';
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_BOOT_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (def->os.nBootDevs == 0) {
|
if (def->os.nBootDevs == 0) {
|
||||||
|
@ -1153,6 +1153,8 @@ xenFormatXLOS(virConf *conf, virDomainDef *def)
|
|||||||
default:
|
default:
|
||||||
boot[i] = 'c';
|
boot[i] = 'c';
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_BOOT_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,6 +457,8 @@ xenFormatXMOS(virConf *conf, virDomainDef *def)
|
|||||||
default:
|
default:
|
||||||
boot[i] = 'c';
|
boot[i] = 'c';
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_BOOT_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6183,7 +6183,7 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < def->os.nBootDevs; i++) {
|
for (i = 0; i < def->os.nBootDevs; i++) {
|
||||||
switch ((virDomainBootOrder) def->os.bootDevs[i]) {
|
switch (def->os.bootDevs[i]) {
|
||||||
case VIR_DOMAIN_BOOT_CDROM:
|
case VIR_DOMAIN_BOOT_CDROM:
|
||||||
bootCD = i + 1;
|
bootCD = i + 1;
|
||||||
break;
|
break;
|
||||||
|
@ -3799,7 +3799,7 @@ prlsdkSetBootOrderVm(PRL_HANDLE sdkdom, virDomainDef *def)
|
|||||||
for (i = 0; i < def->os.nBootDevs; ++i) {
|
for (i = 0; i < def->os.nBootDevs; ++i) {
|
||||||
virType = def->os.bootDevs[i];
|
virType = def->os.bootDevs[i];
|
||||||
|
|
||||||
switch ((int)virType) {
|
switch (virType) {
|
||||||
case VIR_DOMAIN_BOOT_CDROM:
|
case VIR_DOMAIN_BOOT_CDROM:
|
||||||
sdkType = PDE_OPTICAL_DISK;
|
sdkType = PDE_OPTICAL_DISK;
|
||||||
break;
|
break;
|
||||||
@ -3809,6 +3809,8 @@ prlsdkSetBootOrderVm(PRL_HANDLE sdkdom, virDomainDef *def)
|
|||||||
case VIR_DOMAIN_BOOT_NET:
|
case VIR_DOMAIN_BOOT_NET:
|
||||||
sdkType = PDE_GENERIC_NETWORK_ADAPTER;
|
sdkType = PDE_GENERIC_NETWORK_ADAPTER;
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_BOOT_FLOPPY:
|
||||||
|
case VIR_DOMAIN_BOOT_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unsupported boot device type: '%s'"),
|
_("Unsupported boot device type: '%s'"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user