mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
lib: Almost eliminate use of virTristateBoolTypeFromString()
There are couple of places where virTristateBoolTypeFromString() is called. Well, the same result can be achieved by virXMLPropTristateBool() and on fewer lines. Note there are couple of places left untouched because those don't care about error reporting and thus are shorter they way they are now. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9086ae4fac
commit
0fe2d8dd33
@ -328,7 +328,6 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
g_autofree char *cpuMode = NULL;
|
g_autofree char *cpuMode = NULL;
|
||||||
g_autofree char *fallback = NULL;
|
g_autofree char *fallback = NULL;
|
||||||
g_autofree char *vendor_id = NULL;
|
g_autofree char *vendor_id = NULL;
|
||||||
g_autofree char *tscScaling = NULL;
|
|
||||||
g_autofree virHostCPUTscInfo *tsc = NULL;
|
g_autofree virHostCPUTscInfo *tsc = NULL;
|
||||||
|
|
||||||
*cpu = NULL;
|
*cpu = NULL;
|
||||||
@ -427,6 +426,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
|
|
||||||
if (def->type == VIR_CPU_TYPE_HOST) {
|
if (def->type == VIR_CPU_TYPE_HOST) {
|
||||||
g_autofree char *arch = virXPathString("string(./arch[1])", ctxt);
|
g_autofree char *arch = virXPathString("string(./arch[1])", ctxt);
|
||||||
|
xmlNodePtr counter_node = NULL;
|
||||||
|
|
||||||
if (!arch) {
|
if (!arch) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Missing CPU architecture"));
|
_("Missing CPU architecture"));
|
||||||
@ -446,7 +447,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virXPathBoolean("boolean(./counter[@name='tsc'])", ctxt) > 0) {
|
if ((counter_node = virXPathNode("./counter[@name='tsc'])", ctxt))) {
|
||||||
tsc = g_new0(virHostCPUTscInfo, 1);
|
tsc = g_new0(virHostCPUTscInfo, 1);
|
||||||
|
|
||||||
if (virXPathULongLong("string(./counter[@name='tsc']/@frequency)",
|
if (virXPathULongLong("string(./counter[@name='tsc']/@frequency)",
|
||||||
@ -456,17 +457,10 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscScaling = virXPathString("string(./counter[@name='tsc']/@scaling)",
|
if (virXMLPropTristateBool(counter_node, "scaling",
|
||||||
ctxt);
|
VIR_XML_PROP_NONE,
|
||||||
if (tscScaling) {
|
&tsc->scaling) < 0)
|
||||||
int scaling = virTristateBoolTypeFromString(tscScaling);
|
return -1;
|
||||||
if (scaling < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("Invalid TSC scaling attribute"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
tsc->scaling = scaling;
|
|
||||||
}
|
|
||||||
|
|
||||||
def->tsc = g_steal_pointer(&tsc);
|
def->tsc = g_steal_pointer(&tsc);
|
||||||
}
|
}
|
||||||
|
@ -6912,23 +6912,16 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
|
|||||||
virDomainHostdevDef *def,
|
virDomainHostdevDef *def,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
g_autofree char *filtering = NULL;
|
|
||||||
xmlNodePtr address = NULL;
|
xmlNodePtr address = NULL;
|
||||||
xmlNodePtr origstates = NULL;
|
xmlNodePtr origstates = NULL;
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
if ((filtering = virXMLPropString(node, "writeFiltering"))) {
|
if (virXMLPropTristateBool(node, "writeFiltering",
|
||||||
int val;
|
VIR_XML_PROP_NONE,
|
||||||
if ((val = virTristateBoolTypeFromString(filtering)) < 0) {
|
&def->writeFiltering) < 0)
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
return -1;
|
||||||
_("unknown pci writeFiltering setting '%s'"),
|
|
||||||
filtering);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
def->writeFiltering = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((address = virXPathNode("./address", ctxt)) &&
|
if ((address = virXPathNode("./address", ctxt)) &&
|
||||||
virPCIDeviceAddressParseXML(address, &def->source.subsys.u.pci.addr) < 0)
|
virPCIDeviceAddressParseXML(address, &def->source.subsys.u.pci.addr) < 0)
|
||||||
@ -7305,22 +7298,22 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
|
|||||||
virDomainHostdevSubsysSCSI *scsisrc = &def->source.subsys.u.scsi;
|
virDomainHostdevSubsysSCSI *scsisrc = &def->source.subsys.u.scsi;
|
||||||
virDomainHostdevSubsysSCSIVHost *scsihostsrc = &def->source.subsys.u.scsi_host;
|
virDomainHostdevSubsysSCSIVHost *scsihostsrc = &def->source.subsys.u.scsi_host;
|
||||||
virDomainHostdevSubsysMediatedDev *mdevsrc = &def->source.subsys.u.mdev;
|
virDomainHostdevSubsysMediatedDev *mdevsrc = &def->source.subsys.u.mdev;
|
||||||
g_autofree char *managed = NULL;
|
virTristateBool managed;
|
||||||
g_autofree char *sgio = NULL;
|
g_autofree char *sgio = NULL;
|
||||||
g_autofree char *rawio = NULL;
|
|
||||||
g_autofree char *backendStr = NULL;
|
g_autofree char *backendStr = NULL;
|
||||||
g_autofree char *model = NULL;
|
g_autofree char *model = NULL;
|
||||||
|
int rv;
|
||||||
|
|
||||||
/* @managed can be read from the xml document - it is always an
|
/* @managed can be read from the xml document - it is always an
|
||||||
* attribute of the toplevel element, no matter what type of
|
* attribute of the toplevel element, no matter what type of
|
||||||
* element that might be (pure hostdev, or higher level device
|
* element that might be (pure hostdev, or higher level device
|
||||||
* (e.g. <interface>) with type='hostdev')
|
* (e.g. <interface>) with type='hostdev')
|
||||||
*/
|
*/
|
||||||
if ((managed = virXMLPropString(node, "managed")) != NULL)
|
ignore_value(virXMLPropTristateBool(node, "managed",
|
||||||
ignore_value(virStringParseYesNo(managed, &def->managed));
|
VIR_XML_PROP_NONE, &managed));
|
||||||
|
virTristateBoolToBool(managed, &def->managed);
|
||||||
|
|
||||||
sgio = virXMLPropString(node, "sgio");
|
sgio = virXMLPropString(node, "sgio");
|
||||||
rawio = virXMLPropString(node, "rawio");
|
|
||||||
model = virXMLPropString(node, "model");
|
model = virXMLPropString(node, "model");
|
||||||
|
|
||||||
/* @type is passed in from the caller rather than read from the
|
/* @type is passed in from the caller rather than read from the
|
||||||
@ -7373,19 +7366,15 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawio) {
|
if ((rv = virXMLPropTristateBool(node, "rawio",
|
||||||
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
&scsisrc->rawio)) < 0) {
|
||||||
_("rawio is only supported for scsi host device"));
|
return -1;
|
||||||
return -1;
|
} else if (rv > 0 &&
|
||||||
}
|
def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
if ((scsisrc->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
|
_("rawio is only supported for scsi host device"));
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
return -1;
|
||||||
_("unknown hostdev rawio setting '%s'"),
|
|
||||||
rawio);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
|
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
|
||||||
@ -10259,6 +10248,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
xmlNodePtr vlan_node = NULL;
|
xmlNodePtr vlan_node = NULL;
|
||||||
xmlNodePtr bandwidth_node = NULL;
|
xmlNodePtr bandwidth_node = NULL;
|
||||||
xmlNodePtr tmpNode;
|
xmlNodePtr tmpNode;
|
||||||
|
xmlNodePtr mac_node = NULL;
|
||||||
g_autoptr(GHashTable) filterparams = NULL;
|
g_autoptr(GHashTable) filterparams = NULL;
|
||||||
virDomainActualNetDef *actual = NULL;
|
virDomainActualNetDef *actual = NULL;
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
@ -10266,7 +10256,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
int rv, val;
|
int rv, val;
|
||||||
g_autofree char *macaddr = NULL;
|
g_autofree char *macaddr = NULL;
|
||||||
g_autofree char *macaddr_type = NULL;
|
g_autofree char *macaddr_type = NULL;
|
||||||
g_autofree char *macaddr_check = NULL;
|
|
||||||
g_autofree char *network = NULL;
|
g_autofree char *network = NULL;
|
||||||
g_autofree char *portgroup = NULL;
|
g_autofree char *portgroup = NULL;
|
||||||
g_autofree char *portid = NULL;
|
g_autofree char *portid = NULL;
|
||||||
@ -10467,7 +10456,9 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
if ((vhost = virXPathString("string(./backend/@vhost)", ctxt)))
|
if ((vhost = virXPathString("string(./backend/@vhost)", ctxt)))
|
||||||
vhost_path = virFileSanitizePath(vhost);
|
vhost_path = virFileSanitizePath(vhost);
|
||||||
|
|
||||||
if ((macaddr = virXPathString("string(./mac/@address)", ctxt))) {
|
mac_node = virXPathNode("./mac", ctxt);
|
||||||
|
|
||||||
|
if ((macaddr = virXMLPropString(mac_node, "address"))) {
|
||||||
if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) {
|
if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unable to parse mac address '%s'"),
|
_("unable to parse mac address '%s'"),
|
||||||
@ -10498,17 +10489,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
def->mac_type = tmp;
|
def->mac_type = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((macaddr_check = virXPathString("string(./mac/@check)", ctxt))) {
|
if (virXMLPropTristateBool(mac_node, "check",
|
||||||
int tmpCheck;
|
VIR_XML_PROP_NONE,
|
||||||
|
&def->mac_check) < 0)
|
||||||
if ((tmpCheck = virTristateBoolTypeFromString(macaddr_check)) < 0) {
|
goto error;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("invalid mac address check value: '%s'"),
|
|
||||||
macaddr_check);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
def->mac_check = tmpCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
|
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
|
||||||
flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT
|
flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT
|
||||||
@ -14165,40 +14149,21 @@ static virDomainVideoAccelDef *
|
|||||||
virDomainVideoAccelDefParseXML(xmlNodePtr node)
|
virDomainVideoAccelDefParseXML(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
g_autofree virDomainVideoAccelDef *def = NULL;
|
g_autofree virDomainVideoAccelDef *def = NULL;
|
||||||
int val;
|
|
||||||
g_autofree char *accel2d = NULL;
|
|
||||||
g_autofree char *accel3d = NULL;
|
|
||||||
g_autofree char *rendernode = NULL;
|
g_autofree char *rendernode = NULL;
|
||||||
|
|
||||||
accel3d = virXMLPropString(node, "accel3d");
|
|
||||||
accel2d = virXMLPropString(node, "accel2d");
|
|
||||||
rendernode = virXMLPropString(node, "rendernode");
|
rendernode = virXMLPropString(node, "rendernode");
|
||||||
|
|
||||||
if (!accel3d && !accel2d && !rendernode) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("missing values for acceleration"));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
def = g_new0(virDomainVideoAccelDef, 1);
|
def = g_new0(virDomainVideoAccelDef, 1);
|
||||||
|
|
||||||
if (accel3d) {
|
if (virXMLPropTristateBool(node, "accel3d",
|
||||||
if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
&def->accel3d) < 0)
|
||||||
_("unknown accel3d value '%s'"), accel3d);
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
def->accel3d = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (accel2d) {
|
if (virXMLPropTristateBool(node, "accel2d",
|
||||||
if ((val = virTristateBoolTypeFromString(accel2d)) <= 0) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
&def->accel2d) < 0)
|
||||||
_("unknown accel2d value '%s'"), accel2d);
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
def->accel2d = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rendernode)
|
if (rendernode)
|
||||||
def->rendernode = virFileSanitizePath(rendernode);
|
def->rendernode = virFileSanitizePath(rendernode);
|
||||||
@ -14633,20 +14598,13 @@ virDomainEventActionParseXML(xmlXPathContextPtr ctxt,
|
|||||||
static int
|
static int
|
||||||
virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
|
virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
|
||||||
const char *xpath,
|
const char *xpath,
|
||||||
int *val)
|
virTristateBool *val)
|
||||||
{
|
{
|
||||||
g_autofree char *tmp = virXPathString(xpath, ctxt);
|
xmlNodePtr node = virXPathNode(xpath, ctxt);
|
||||||
|
|
||||||
if (tmp) {
|
return virXMLPropTristateBool(node, "enabled",
|
||||||
*val = virTristateBoolTypeFromString(tmp);
|
VIR_XML_PROP_NONE,
|
||||||
if (*val < 0) {
|
val);
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown PM state value %s"), tmp);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -16972,19 +16930,10 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((node = virXPathNode("./os/bootmenu[1]", ctxt))) {
|
if ((node = virXPathNode("./os/bootmenu[1]", ctxt))) {
|
||||||
tmp = virXMLPropString(node, "enable");
|
if (virXMLPropTristateBool(node, "enable",
|
||||||
if (tmp) {
|
VIR_XML_PROP_NONE,
|
||||||
def->os.bootmenu = virTristateBoolTypeFromString(tmp);
|
&def->os.bootmenu) < 0)
|
||||||
if (def->os.bootmenu <= 0) {
|
return -1;
|
||||||
/* In order not to break misconfigured machines, this
|
|
||||||
* should not emit an error, but rather set the bootmenu
|
|
||||||
* to disabled */
|
|
||||||
VIR_WARN("disabling bootmenu due to unknown option '%s'",
|
|
||||||
tmp);
|
|
||||||
def->os.bootmenu = VIR_TRISTATE_BOOL_NO;
|
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = virXMLPropString(node, "timeout");
|
tmp = virXMLPropString(node, "timeout");
|
||||||
if (tmp && def->os.bootmenu == VIR_TRISTATE_BOOL_YES) {
|
if (tmp && def->os.bootmenu == VIR_TRISTATE_BOOL_YES) {
|
||||||
@ -18388,26 +18337,21 @@ virDomainDefParseBootFirmwareOptions(virDomainDef *def,
|
|||||||
features = g_new0(int, VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST);
|
features = g_new0(int, VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
g_autofree char *name = virXMLPropString(nodes[i], "name");
|
unsigned int feature;
|
||||||
g_autofree char *enabled = virXMLPropString(nodes[i], "enabled");
|
virTristateBool enabled;
|
||||||
int feature = virDomainOsDefFirmwareFeatureTypeFromString(name);
|
|
||||||
int val = virTristateBoolTypeFromString(enabled);
|
|
||||||
|
|
||||||
if (feature < 0) {
|
if (virXMLPropEnum(nodes[i], "name",
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virDomainOsDefFirmwareFeatureTypeFromString,
|
||||||
_("invalid firmware feature name '%s'"),
|
VIR_XML_PROP_REQUIRED,
|
||||||
name);
|
&feature) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (val < 0) {
|
if (virXMLPropTristateBool(nodes[i], "enabled",
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
VIR_XML_PROP_REQUIRED,
|
||||||
_("invalid firmware feature enabled value '%s'"),
|
&enabled) < 0)
|
||||||
enabled);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
features[feature] = val;
|
features[feature] = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->os.firmwareFeatures = g_steal_pointer(&features);
|
def->os.firmwareFeatures = g_steal_pointer(&features);
|
||||||
@ -19523,12 +19467,12 @@ virDomainDefLifecycleParse(virDomainDef *def,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virDomainPMStateParseXML(ctxt,
|
if (virDomainPMStateParseXML(ctxt,
|
||||||
"string(./pm/suspend-to-mem/@enabled)",
|
"./pm/suspend-to-mem",
|
||||||
&def->pm.s3) < 0)
|
&def->pm.s3) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virDomainPMStateParseXML(ctxt,
|
if (virDomainPMStateParseXML(ctxt,
|
||||||
"string(./pm/suspend-to-disk/@enabled)",
|
"./pm/suspend-to-disk",
|
||||||
&def->pm.s4) < 0)
|
&def->pm.s4) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -30565,6 +30509,7 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDef *iface,
|
|||||||
break;
|
break;
|
||||||
case VIR_TRISTATE_BOOL_ABSENT:
|
case VIR_TRISTATE_BOOL_ABSENT:
|
||||||
case VIR_TRISTATE_BOOL_NO:
|
case VIR_TRISTATE_BOOL_NO:
|
||||||
|
case VIR_TRISTATE_BOOL_LAST:
|
||||||
actual->data.hostdev.def.managed = false;
|
actual->data.hostdev.def.managed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ struct _virDomainHostdevSubsysSCSIiSCSI {
|
|||||||
struct _virDomainHostdevSubsysSCSI {
|
struct _virDomainHostdevSubsysSCSI {
|
||||||
int protocol; /* enum virDomainHostdevSCSIProtocolType */
|
int protocol; /* enum virDomainHostdevSCSIProtocolType */
|
||||||
int sgio; /* enum virDomainDeviceSGIO */
|
int sgio; /* enum virDomainDeviceSGIO */
|
||||||
int rawio; /* enum virTristateBool */
|
virTristateBool rawio;
|
||||||
union {
|
union {
|
||||||
virDomainHostdevSubsysSCSIHost host;
|
virDomainHostdevSubsysSCSIHost host;
|
||||||
virDomainHostdevSubsysSCSIiSCSI iscsi;
|
virDomainHostdevSubsysSCSIiSCSI iscsi;
|
||||||
@ -1706,8 +1706,8 @@ typedef enum {
|
|||||||
VIR_ENUM_DECL(virDomainVideoVGAConf);
|
VIR_ENUM_DECL(virDomainVideoVGAConf);
|
||||||
|
|
||||||
struct _virDomainVideoAccelDef {
|
struct _virDomainVideoAccelDef {
|
||||||
int accel2d; /* enum virTristateBool */
|
virTristateBool accel2d;
|
||||||
int accel3d; /* enum virTristateBool */
|
virTristateBool accel3d;
|
||||||
char *rendernode;
|
char *rendernode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2325,7 +2325,7 @@ struct _virDomainOSDef {
|
|||||||
char *machine;
|
char *machine;
|
||||||
size_t nBootDevs;
|
size_t nBootDevs;
|
||||||
int bootDevs[VIR_DOMAIN_BOOT_LAST];
|
int bootDevs[VIR_DOMAIN_BOOT_LAST];
|
||||||
int bootmenu; /* enum virTristateBool */
|
virTristateBool bootmenu;
|
||||||
unsigned int bm_timeout;
|
unsigned int bm_timeout;
|
||||||
bool bm_timeout_set;
|
bool bm_timeout_set;
|
||||||
char *init;
|
char *init;
|
||||||
@ -2688,9 +2688,8 @@ struct _virDomainMemtune {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainPowerManagement {
|
struct _virDomainPowerManagement {
|
||||||
/* These options are of type enum virTristateBool */
|
virTristateBool s3;
|
||||||
int s3;
|
virTristateBool s4;
|
||||||
int s4;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainPerfDef {
|
struct _virDomainPerfDef {
|
||||||
|
@ -928,37 +928,21 @@ virNetworkDNSDefParseXML(const char *networkName,
|
|||||||
g_autofree xmlNodePtr *srvNodes = NULL;
|
g_autofree xmlNodePtr *srvNodes = NULL;
|
||||||
g_autofree xmlNodePtr *txtNodes = NULL;
|
g_autofree xmlNodePtr *txtNodes = NULL;
|
||||||
g_autofree xmlNodePtr *fwdNodes = NULL;
|
g_autofree xmlNodePtr *fwdNodes = NULL;
|
||||||
g_autofree char *forwardPlainNames = NULL;
|
|
||||||
g_autofree char *enable = NULL;
|
|
||||||
int nhosts, nsrvs, ntxts, nfwds;
|
int nhosts, nsrvs, ntxts, nfwds;
|
||||||
size_t i;
|
size_t i;
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
enable = virXPathString("string(./@enable)", ctxt);
|
if (virXMLPropTristateBool(node, "enable",
|
||||||
if (enable) {
|
VIR_XML_PROP_NONE,
|
||||||
def->enable = virTristateBoolTypeFromString(enable);
|
&def->enable) < 0)
|
||||||
if (def->enable <= 0) {
|
return -1;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid dns enable setting '%s' "
|
|
||||||
"in network '%s'"),
|
|
||||||
enable, networkName);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forwardPlainNames = virXPathString("string(./@forwardPlainNames)", ctxt);
|
if (virXMLPropTristateBool(node, "forwardPlainNames",
|
||||||
if (forwardPlainNames) {
|
VIR_XML_PROP_NONE,
|
||||||
def->forwardPlainNames = virTristateBoolTypeFromString(forwardPlainNames);
|
&def->forwardPlainNames) < 0)
|
||||||
if (def->forwardPlainNames <= 0) {
|
return -1;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid dns forwardPlainNames setting '%s' "
|
|
||||||
"in network '%s'"),
|
|
||||||
forwardPlainNames, networkName);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes);
|
nfwds = virXPathNodeSet("./forwarder", ctxt, &fwdNodes);
|
||||||
if (nfwds < 0) {
|
if (nfwds < 0) {
|
||||||
@ -1076,7 +1060,6 @@ virNetworkIPDefParseXML(const char *networkName,
|
|||||||
xmlNodePtr dhcp;
|
xmlNodePtr dhcp;
|
||||||
g_autofree char *address = NULL;
|
g_autofree char *address = NULL;
|
||||||
g_autofree char *netmask = NULL;
|
g_autofree char *netmask = NULL;
|
||||||
g_autofree char *localPtr = NULL;
|
|
||||||
unsigned long prefix = 0;
|
unsigned long prefix = 0;
|
||||||
int prefixRc;
|
int prefixRc;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1121,16 +1104,10 @@ virNetworkIPDefParseXML(const char *networkName,
|
|||||||
else
|
else
|
||||||
def->prefix = prefix;
|
def->prefix = prefix;
|
||||||
|
|
||||||
localPtr = virXPathString("string(./@localPtr)", ctxt);
|
if (virXMLPropTristateBool(node, "localPtr",
|
||||||
if (localPtr) {
|
VIR_XML_PROP_NONE,
|
||||||
def->localPTR = virTristateBoolTypeFromString(localPtr);
|
&def->localPTR) < 0)
|
||||||
if (def->localPTR <= 0) {
|
goto cleanup;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid localPtr value '%s' in network '%s'"),
|
|
||||||
localPtr, networkName);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* validate address, etc. for each family */
|
/* validate address, etc. for each family */
|
||||||
if ((def->family == NULL) || (STREQ(def->family, "ipv4"))) {
|
if ((def->family == NULL) || (STREQ(def->family, "ipv4"))) {
|
||||||
@ -1217,19 +1194,11 @@ int
|
|||||||
virNetworkPortOptionsParseXML(xmlXPathContextPtr ctxt,
|
virNetworkPortOptionsParseXML(xmlXPathContextPtr ctxt,
|
||||||
virTristateBool *isolatedPort)
|
virTristateBool *isolatedPort)
|
||||||
{
|
{
|
||||||
g_autofree char *str = NULL;
|
xmlNodePtr port_node = virXPathNode("./port", ctxt);
|
||||||
int tmp = VIR_TRISTATE_BOOL_ABSENT;
|
|
||||||
|
|
||||||
if ((str = virXPathString("string(./port/@isolated)", ctxt))) {
|
return virXMLPropTristateBool(port_node, "isolated",
|
||||||
if ((tmp = virTristateBoolTypeFromString(str)) <= 0) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
isolatedPort);
|
||||||
_("unknown port isolated value '%s'"), str);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*isolatedPort = tmp;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1248,7 +1217,6 @@ virNetworkPortGroupParseXML(virPortGroupDef *def,
|
|||||||
xmlNodePtr vlanNode;
|
xmlNodePtr vlanNode;
|
||||||
xmlNodePtr bandwidth_node;
|
xmlNodePtr bandwidth_node;
|
||||||
g_autofree char *isDefault = NULL;
|
g_autofree char *isDefault = NULL;
|
||||||
g_autofree char *trustGuestRxFilters = NULL;
|
|
||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -1265,17 +1233,10 @@ virNetworkPortGroupParseXML(virPortGroupDef *def,
|
|||||||
isDefault = virXPathString("string(./@default)", ctxt);
|
isDefault = virXPathString("string(./@default)", ctxt);
|
||||||
def->isDefault = isDefault && STRCASEEQ(isDefault, "yes");
|
def->isDefault = isDefault && STRCASEEQ(isDefault, "yes");
|
||||||
|
|
||||||
trustGuestRxFilters
|
if (virXMLPropTristateBool(node, "trustGuestRxFilters",
|
||||||
= virXPathString("string(./@trustGuestRxFilters)", ctxt);
|
VIR_XML_PROP_NONE,
|
||||||
if (trustGuestRxFilters) {
|
&def->trustGuestRxFilters) < 0)
|
||||||
if ((def->trustGuestRxFilters
|
goto cleanup;
|
||||||
= virTristateBoolTypeFromString(trustGuestRxFilters)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid trustGuestRxFilters setting '%s' "
|
|
||||||
"in portgroup"), trustGuestRxFilters);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtPortNode = virXPathNode("./virtualport", ctxt);
|
virtPortNode = virXPathNode("./virtualport", ctxt);
|
||||||
if (virtPortNode &&
|
if (virtPortNode &&
|
||||||
@ -1662,7 +1623,6 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
{
|
{
|
||||||
g_autoptr(virNetworkDef) def = NULL;
|
g_autoptr(virNetworkDef) def = NULL;
|
||||||
g_autofree char *uuid = NULL;
|
g_autofree char *uuid = NULL;
|
||||||
g_autofree char *localOnly = NULL;
|
|
||||||
g_autofree char *stp = NULL;
|
g_autofree char *stp = NULL;
|
||||||
g_autofree char *stpDelay = NULL;
|
g_autofree char *stpDelay = NULL;
|
||||||
g_autofree char *macTableManager = NULL;
|
g_autofree char *macTableManager = NULL;
|
||||||
@ -1676,11 +1636,11 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
xmlNodePtr virtPortNode = NULL;
|
xmlNodePtr virtPortNode = NULL;
|
||||||
xmlNodePtr forwardNode = NULL;
|
xmlNodePtr forwardNode = NULL;
|
||||||
g_autofree char *ipv6nogwStr = NULL;
|
g_autofree char *ipv6nogwStr = NULL;
|
||||||
g_autofree char *trustGuestRxFilters = NULL;
|
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
xmlNodePtr bandwidthNode = NULL;
|
xmlNodePtr bandwidthNode = NULL;
|
||||||
xmlNodePtr vlanNode;
|
xmlNodePtr vlanNode;
|
||||||
xmlNodePtr metadataNode = NULL;
|
xmlNodePtr metadataNode = NULL;
|
||||||
|
xmlNodePtr domain_node = NULL;
|
||||||
|
|
||||||
def = g_new0(virNetworkDef, 1);
|
def = g_new0(virNetworkDef, 1);
|
||||||
|
|
||||||
@ -1724,32 +1684,18 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trustGuestRxFilters
|
if (virXMLPropTristateBool(ctxt->node, "trustGuestRxFilters",
|
||||||
= virXPathString("string(./@trustGuestRxFilters)", ctxt);
|
VIR_XML_PROP_NONE,
|
||||||
if (trustGuestRxFilters) {
|
&def->trustGuestRxFilters) < 0)
|
||||||
if ((def->trustGuestRxFilters
|
return NULL;
|
||||||
= virTristateBoolTypeFromString(trustGuestRxFilters)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid trustGuestRxFilters setting '%s' "
|
|
||||||
"in network '%s'"),
|
|
||||||
trustGuestRxFilters, def->name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse network domain information */
|
/* Parse network domain information */
|
||||||
def->domain = virXPathString("string(./domain[1]/@name)", ctxt);
|
domain_node = virXPathNode("./domain[1]", ctxt);
|
||||||
localOnly = virXPathString("string(./domain[1]/@localOnly)", ctxt);
|
def->domain = virXMLPropString(domain_node, "name");
|
||||||
if (localOnly) {
|
if (virXMLPropTristateBool(domain_node, "localOnly",
|
||||||
def->domainLocalOnly = virTristateBoolTypeFromString(localOnly);
|
VIR_XML_PROP_NONE,
|
||||||
if (def->domainLocalOnly <= 0) {
|
&def->domainLocalOnly) < 0)
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
return NULL;
|
||||||
_("Invalid domain localOnly setting '%s' "
|
|
||||||
"in network '%s'"),
|
|
||||||
localOnly, def->name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
|
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
|
||||||
virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidthNode, false) < 0)
|
virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidthNode, false) < 0)
|
||||||
|
@ -158,8 +158,8 @@ struct _virNetworkDNSForwarder {
|
|||||||
|
|
||||||
typedef struct _virNetworkDNSDef virNetworkDNSDef;
|
typedef struct _virNetworkDNSDef virNetworkDNSDef;
|
||||||
struct _virNetworkDNSDef {
|
struct _virNetworkDNSDef {
|
||||||
int enable; /* enum virTristateBool */
|
virTristateBool enable;
|
||||||
int forwardPlainNames; /* enum virTristateBool */
|
virTristateBool forwardPlainNames;
|
||||||
size_t ntxts;
|
size_t ntxts;
|
||||||
virNetworkDNSTxtDef *txts;
|
virNetworkDNSTxtDef *txts;
|
||||||
size_t nhosts;
|
size_t nhosts;
|
||||||
@ -184,7 +184,7 @@ struct _virNetworkIPDef {
|
|||||||
unsigned int prefix; /* ipv6 - only prefix allowed */
|
unsigned int prefix; /* ipv6 - only prefix allowed */
|
||||||
virSocketAddr netmask; /* ipv4 - either netmask or prefix specified */
|
virSocketAddr netmask; /* ipv4 - either netmask or prefix specified */
|
||||||
|
|
||||||
int localPTR; /* virTristateBool */
|
virTristateBool localPTR;
|
||||||
|
|
||||||
size_t nranges; /* Zero or more dhcp ranges */
|
size_t nranges; /* Zero or more dhcp ranges */
|
||||||
virNetworkDHCPRangeDef *ranges;
|
virNetworkDHCPRangeDef *ranges;
|
||||||
@ -243,7 +243,7 @@ struct _virPortGroupDef {
|
|||||||
virNetDevVPortProfile *virtPortProfile;
|
virNetDevVPortProfile *virtPortProfile;
|
||||||
virNetDevBandwidth *bandwidth;
|
virNetDevBandwidth *bandwidth;
|
||||||
virNetDevVlan vlan;
|
virNetDevVlan vlan;
|
||||||
int trustGuestRxFilters; /* enum virTristateBool */
|
virTristateBool trustGuestRxFilters;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _virNetworkDef virNetworkDef;
|
typedef struct _virNetworkDef virNetworkDef;
|
||||||
@ -257,7 +257,7 @@ struct _virNetworkDef {
|
|||||||
char *bridgeZone; /* name of firewalld zone for bridge */
|
char *bridgeZone; /* name of firewalld zone for bridge */
|
||||||
int macTableManager; /* enum virNetworkBridgeMACTableManager */
|
int macTableManager; /* enum virNetworkBridgeMACTableManager */
|
||||||
char *domain;
|
char *domain;
|
||||||
int domainLocalOnly; /* enum virTristateBool: yes disables dns forwarding */
|
virTristateBool domainLocalOnly; /* yes disables dns forwarding */
|
||||||
unsigned long delay; /* Bridge forward delay (ms) */
|
unsigned long delay; /* Bridge forward delay (ms) */
|
||||||
bool stp; /* Spanning tree protocol */
|
bool stp; /* Spanning tree protocol */
|
||||||
unsigned int mtu; /* MTU for bridge, 0 means "default" i.e. unset in config */
|
unsigned int mtu; /* MTU for bridge, 0 means "default" i.e. unset in config */
|
||||||
@ -284,7 +284,7 @@ struct _virNetworkDef {
|
|||||||
virPortGroupDef *portGroups;
|
virPortGroupDef *portGroups;
|
||||||
virNetDevBandwidth *bandwidth;
|
virNetDevBandwidth *bandwidth;
|
||||||
virNetDevVlan vlan;
|
virNetDevVlan vlan;
|
||||||
int trustGuestRxFilters; /* enum virTristateBool */
|
virTristateBool trustGuestRxFilters;
|
||||||
virTristateBool isolatedPort;
|
virTristateBool isolatedPort;
|
||||||
|
|
||||||
/* Application-specific custom metadata */
|
/* Application-specific custom metadata */
|
||||||
|
@ -804,22 +804,21 @@ static int
|
|||||||
virStoragePoolDefParseFeatures(virStoragePoolDef *def,
|
virStoragePoolDefParseFeatures(virStoragePoolDef *def,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
g_autofree char *cow = virXPathString("string(./features/cow/@state)", ctxt);
|
xmlNodePtr node = virXPathNode("./features/cow", ctxt);
|
||||||
|
virTristateBool val;
|
||||||
|
int rv;
|
||||||
|
|
||||||
if (cow) {
|
if ((rv = virXMLPropTristateBool(node, "state",
|
||||||
int val;
|
VIR_XML_PROP_NONE,
|
||||||
|
&val)) < 0) {
|
||||||
|
return -1;
|
||||||
|
} else if (rv > 0) {
|
||||||
if (def->type != VIR_STORAGE_POOL_FS &&
|
if (def->type != VIR_STORAGE_POOL_FS &&
|
||||||
def->type != VIR_STORAGE_POOL_DIR) {
|
def->type != VIR_STORAGE_POOL_DIR) {
|
||||||
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("cow feature may only be used for 'fs' and 'dir' pools"));
|
_("cow feature may only be used for 'fs' and 'dir' pools"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((val = virTristateBoolTypeFromString(cow)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("invalid storage pool cow feature state '%s'"),
|
|
||||||
cow);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
def->features.cow = val;
|
def->features.cow = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,24 +322,16 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
{
|
{
|
||||||
virStoragePRDef *prd;
|
virStoragePRDef *prd;
|
||||||
virStoragePRDef *ret = NULL;
|
virStoragePRDef *ret = NULL;
|
||||||
g_autofree char *managed = NULL;
|
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
g_autofree char *mode = NULL;
|
g_autofree char *mode = NULL;
|
||||||
|
|
||||||
prd = g_new0(virStoragePRDef, 1);
|
prd = g_new0(virStoragePRDef, 1);
|
||||||
|
|
||||||
if (!(managed = virXPathString("string(./@managed)", ctxt))) {
|
if (virXMLPropTristateBool(ctxt->node, "managed",
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
VIR_XML_PROP_REQUIRED,
|
||||||
_("missing @managed attribute for <reservations/>"));
|
&prd->managed) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if ((prd->managed = virTristateBoolTypeFromString(managed)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("invalid value for 'managed': %s"), managed);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = virXPathString("string(./source[1]/@type)", ctxt);
|
type = virXPathString("string(./source[1]/@type)", ctxt);
|
||||||
path = virXPathString("string(./source[1]/@path)", ctxt);
|
path = virXPathString("string(./source[1]/@path)", ctxt);
|
||||||
|
@ -226,7 +226,7 @@ struct _virStorageAuthDef {
|
|||||||
|
|
||||||
typedef struct _virStoragePRDef virStoragePRDef;
|
typedef struct _virStoragePRDef virStoragePRDef;
|
||||||
struct _virStoragePRDef {
|
struct _virStoragePRDef {
|
||||||
int managed; /* enum virTristateBool */
|
virTristateBool managed;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
/* manager object alias */
|
/* manager object alias */
|
||||||
|
@ -87,12 +87,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
xmlNodePtr vlanNode;
|
xmlNodePtr vlanNode;
|
||||||
xmlNodePtr bandwidthNode;
|
xmlNodePtr bandwidthNode;
|
||||||
xmlNodePtr addressNode;
|
xmlNodePtr addressNode;
|
||||||
g_autofree char *trustGuestRxFilters = NULL;
|
xmlNodePtr rxfiltersNode = NULL;
|
||||||
|
xmlNodePtr plugNode = NULL;
|
||||||
g_autofree char *mac = NULL;
|
g_autofree char *mac = NULL;
|
||||||
g_autofree char *macmgr = NULL;
|
g_autofree char *macmgr = NULL;
|
||||||
g_autofree char *mode = NULL;
|
g_autofree char *mode = NULL;
|
||||||
g_autofree char *plugtype = NULL;
|
g_autofree char *plugtype = NULL;
|
||||||
g_autofree char *managed = NULL;
|
|
||||||
g_autofree char *driver = NULL;
|
g_autofree char *driver = NULL;
|
||||||
|
|
||||||
def = g_new0(virNetworkPortDef, 1);
|
def = g_new0(virNetworkPortDef, 1);
|
||||||
@ -169,18 +169,13 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0)
|
if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
trustGuestRxFilters
|
rxfiltersNode = virXPathNode("./rxfilters", ctxt);
|
||||||
= virXPathString("string(./rxfilters/@trustGuest)", ctxt);
|
if (virXMLPropTristateBool(rxfiltersNode, "trustGuest",
|
||||||
if (trustGuestRxFilters) {
|
VIR_XML_PROP_NONE,
|
||||||
if ((def->trustGuestRxFilters
|
&def->trustGuestRxFilters) < 0)
|
||||||
= virTristateBoolTypeFromString(trustGuestRxFilters)) <= 0) {
|
return NULL;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid guest rx filters trust setting '%s' "),
|
|
||||||
trustGuestRxFilters);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
plugNode = virXPathNode("./plug", ctxt);
|
||||||
plugtype = virXPathString("string(./plug/@type)", ctxt);
|
plugtype = virXPathString("string(./plug/@type)", ctxt);
|
||||||
|
|
||||||
if (plugtype &&
|
if (plugtype &&
|
||||||
@ -228,14 +223,10 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_NETWORK_PORT_PLUG_TYPE_HOSTDEV_PCI:
|
case VIR_NETWORK_PORT_PLUG_TYPE_HOSTDEV_PCI:
|
||||||
managed = virXPathString("string(./plug/@managed)", ctxt);
|
if (virXMLPropTristateBool(plugNode, "managed",
|
||||||
if (managed &&
|
VIR_XML_PROP_NONE,
|
||||||
(def->plug.hostdevpci.managed =
|
&def->plug.hostdevpci.managed) < 0)
|
||||||
virTristateBoolTypeFromString(managed)) < 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid managed setting '%s' in network port"), mode);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
driver = virXPathString("string(./plug/driver/@name)", ctxt);
|
driver = virXPathString("string(./plug/driver/@name)", ctxt);
|
||||||
if (driver &&
|
if (driver &&
|
||||||
(def->plug.hostdevpci.driver =
|
(def->plug.hostdevpci.driver =
|
||||||
|
@ -55,7 +55,7 @@ struct _virNetworkPortDef {
|
|||||||
virNetDevBandwidth *bandwidth;
|
virNetDevBandwidth *bandwidth;
|
||||||
unsigned int class_id; /* class ID for bandwidth 'floor' */
|
unsigned int class_id; /* class ID for bandwidth 'floor' */
|
||||||
virNetDevVlan vlan;
|
virNetDevVlan vlan;
|
||||||
int trustGuestRxFilters; /* enum virTristateBool */
|
virTristateBool trustGuestRxFilters;
|
||||||
virTristateBool isolatedPort;
|
virTristateBool isolatedPort;
|
||||||
|
|
||||||
int plugtype; /* virNetworkPortPlugType */
|
int plugtype; /* virNetworkPortPlugType */
|
||||||
@ -71,7 +71,7 @@ struct _virNetworkPortDef {
|
|||||||
struct {
|
struct {
|
||||||
virPCIDeviceAddress addr; /* PCI Address of device */
|
virPCIDeviceAddress addr; /* PCI Address of device */
|
||||||
int driver; /* virNetworkForwardDriverNameType */
|
int driver; /* virNetworkForwardDriverNameType */
|
||||||
int managed;
|
virTristateBool managed;
|
||||||
} hostdevpci;
|
} hostdevpci;
|
||||||
} plug;
|
} plug;
|
||||||
};
|
};
|
||||||
|
@ -1603,8 +1603,8 @@ x86ModelParseFeatures(virCPUx86Model *model,
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
g_autofree char *ftname = NULL;
|
g_autofree char *ftname = NULL;
|
||||||
g_autofree char *removed = NULL;
|
|
||||||
virCPUx86Feature *feature;
|
virCPUx86Feature *feature;
|
||||||
|
virTristateBool rem;
|
||||||
|
|
||||||
if (!(ftname = virXMLPropString(nodes[i], "name"))) {
|
if (!(ftname = virXMLPropString(nodes[i], "name"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1620,21 +1620,14 @@ x86ModelParseFeatures(virCPUx86Model *model,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((removed = virXMLPropString(nodes[i], "removed"))) {
|
if (virXMLPropTristateBool(nodes[i], "removed",
|
||||||
int rem;
|
VIR_XML_PROP_NONE,
|
||||||
|
&rem) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if ((rem = virTristateBoolTypeFromString(removed)) < 0) {
|
if (rem == VIR_TRISTATE_BOOL_YES) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
model->removedFeatures[nremoved++] = g_strdup(ftname);
|
||||||
_("Invalid 'removed' attribute for feature %s "
|
continue;
|
||||||
"in model %s"),
|
|
||||||
ftname, model->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rem == VIR_TRISTATE_BOOL_YES) {
|
|
||||||
model->removedFeatures[nremoved++] = g_strdup(ftname);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x86DataAdd(&model->data, &feature->data))
|
if (x86DataAdd(&model->data, &feature->data))
|
||||||
|
@ -3758,7 +3758,6 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
|||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
const char *typeStr)
|
const char *typeStr)
|
||||||
{
|
{
|
||||||
g_autofree char *migratability = NULL;
|
|
||||||
xmlNodePtr hostCPUNode;
|
xmlNodePtr hostCPUNode;
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
@ -3766,6 +3765,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
|||||||
g_autofree char *xpath = g_strdup_printf("./hostCPU[@type='%s']", typeStr);
|
g_autofree char *xpath = g_strdup_printf("./hostCPU[@type='%s']", typeStr);
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
|
virTristateBool migratability;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
if (!(hostCPUNode = virXPathNode(xpath, ctxt))) {
|
if (!(hostCPUNode = virXPathNode(xpath, ctxt))) {
|
||||||
@ -3781,13 +3781,12 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(migratability = virXMLPropString(hostCPUNode, "migratability")) ||
|
if (virXMLPropTristateBool(hostCPUNode, "migratability",
|
||||||
(val = virTristateBoolTypeFromString(migratability)) <= 0) {
|
VIR_XML_PROP_REQUIRED,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
&migratability) < 0)
|
||||||
_("invalid migratability value for host CPU model"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
hostCPU->migratability = val == VIR_TRISTATE_BOOL_YES;
|
virTristateBoolToBool(migratability, &hostCPU->migratability);
|
||||||
|
|
||||||
ctxt->node = hostCPUNode;
|
ctxt->node = hostCPUNode;
|
||||||
|
|
||||||
@ -3798,7 +3797,6 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
|||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
qemuMonitorCPUProperty *prop = hostCPU->props + i;
|
qemuMonitorCPUProperty *prop = hostCPU->props + i;
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
g_autofree char *migratable = NULL;
|
|
||||||
|
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
|
|
||||||
@ -3850,17 +3848,11 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((migratable = virXMLPropString(ctxt->node, "migratable"))) {
|
if (virXMLPropTristateBool(ctxt->node, "migratable",
|
||||||
if ((val = virTristateBoolTypeFromString(migratable)) <= 0) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
&prop->migratable) < 0)
|
||||||
_("unknown migratable value for '%s' host "
|
return -1;
|
||||||
"CPU model property"),
|
|
||||||
prop->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
prop->migratable = val;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2829,19 +2829,11 @@ int
|
|||||||
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
|
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
|
||||||
virTristateBool *allowReboot)
|
virTristateBool *allowReboot)
|
||||||
{
|
{
|
||||||
int val;
|
xmlNodePtr node = virXPathNode("./allowReboot", ctxt);
|
||||||
g_autofree char *valStr = NULL;
|
|
||||||
|
|
||||||
if ((valStr = virXPathString("string(./allowReboot/@value)", ctxt))) {
|
return virXMLPropTristateBool(node, "value",
|
||||||
if ((val = virTristateBoolTypeFromString(valStr)) < 0) {
|
VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
allowReboot);
|
||||||
_("invalid allowReboot value '%s'"), valStr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*allowReboot = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user