mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
conf: Convert virNetworkPortDefParseXML() to virXMLProp*()
After previous cleanups, the virNetworkPortDefParseXML() 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
97129ed43a
commit
af5a7dba78
@ -92,7 +92,6 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
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 *driver = NULL;
|
g_autofree char *driver = NULL;
|
||||||
|
|
||||||
def = g_new0(virNetworkPortDef, 1);
|
def = g_new0(virNetworkPortDef, 1);
|
||||||
@ -176,13 +175,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
plugNode = virXPathNode("./plug", ctxt);
|
plugNode = virXPathNode("./plug", ctxt);
|
||||||
plugtype = virXPathString("string(./plug/@type)", ctxt);
|
|
||||||
|
|
||||||
if (plugtype &&
|
if (virXMLPropEnum(plugNode, "type",
|
||||||
(def->plugtype = virNetworkPortPlugTypeFromString(plugtype)) < 0) {
|
virNetworkPortPlugTypeFromString,
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
VIR_XML_PROP_NONE,
|
||||||
_("Invalid network port plug type '%s'"), plugtype);
|
&def->plugtype) < 0)
|
||||||
}
|
return NULL;
|
||||||
|
|
||||||
switch (def->plugtype) {
|
switch (def->plugtype) {
|
||||||
case VIR_NETWORK_PORT_PLUG_TYPE_NONE:
|
case VIR_NETWORK_PORT_PLUG_TYPE_NONE:
|
||||||
@ -190,12 +188,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
|
|
||||||
case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK:
|
case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK:
|
||||||
case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE:
|
case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE:
|
||||||
if (!(def->plug.bridge.brname = virXPathString("string(./plug/@bridge)", ctxt))) {
|
if (!(def->plug.bridge.brname = virXMLPropString(plugNode, "bridge"))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Missing network port bridge name"));
|
_("Missing network port bridge name"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
macmgr = virXPathString("string(./plug/@macTableManager)", ctxt);
|
macmgr = virXMLPropString(plugNode, "macTableManager");
|
||||||
if (macmgr &&
|
if (macmgr &&
|
||||||
(def->plug.bridge.macTableManager =
|
(def->plug.bridge.macTableManager =
|
||||||
virNetworkBridgeMACTableManagerTypeFromString(macmgr)) <= 0) {
|
virNetworkBridgeMACTableManagerTypeFromString(macmgr)) <= 0) {
|
||||||
@ -207,12 +205,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT:
|
case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT:
|
||||||
if (!(def->plug.direct.linkdev = virXPathString("string(./plug/@dev)", ctxt))) {
|
if (!(def->plug.direct.linkdev = virXMLPropString(plugNode, "dev"))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Missing network port link device name"));
|
_("Missing network port link device name"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
mode = virXPathString("string(./plug/@mode)", ctxt);
|
mode = virXMLPropString(plugNode, "mode");
|
||||||
if (mode &&
|
if (mode &&
|
||||||
(def->plug.direct.mode =
|
(def->plug.direct.mode =
|
||||||
virNetDevMacVLanModeTypeFromString(mode)) < 0) {
|
virNetDevMacVLanModeTypeFromString(mode)) < 0) {
|
||||||
|
@ -58,7 +58,7 @@ struct _virNetworkPortDef {
|
|||||||
virTristateBool trustGuestRxFilters;
|
virTristateBool trustGuestRxFilters;
|
||||||
virTristateBool isolatedPort;
|
virTristateBool isolatedPort;
|
||||||
|
|
||||||
int plugtype; /* virNetworkPortPlugType */
|
virNetworkPortPlugType plugtype;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
char *brname;
|
char *brname;
|
||||||
|
Loading…
Reference in New Issue
Block a user