AVAHI_REQUIRED="0.6.0"
POLKIT_REQUIRED="0.6"
PARTED_REQUIRED="1.8.0"
-NETCF_REQUIRED="0.0.1"
+NETCF_REQUIRED="0.1.3"
dnl Checks for C compiler.
AC_PROG_CC
const char* virInterfaceGetName (virInterfacePtr iface);
const char* virInterfaceGetMACString (virInterfacePtr iface);
+typedef enum {
+ VIR_INTERFACE_XML_INACTIVE = 1 /* dump inactive interface information */
+} virInterfaceXMLFlags;
+
char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags);
virInterfacePtr virInterfaceDefineXML (virConnectPtr conn,
BuildRequires: libssh2-devel
%endif
%if %{with_netcf}
-BuildRequires: netcf-devel
+BuildRequires: netcf-devel >= 0.1.3
%endif
# Fedora build root suckage
static int
virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceDefPtr def,
xmlXPathContextPtr ctxt) {
- xmlNodePtr cur;
- int ret;
+ xmlNodePtr dhcp, ip;
+ int ret = 0;
- cur = virXPathNode(conn, "./dhcp", ctxt);
- if (cur != NULL)
- ret = virInterfaceDefParseDhcp(conn, def, cur, ctxt);
- else {
- cur = virXPathNode(conn, "./ip", ctxt);
- if (cur != NULL)
- ret = virInterfaceDefParseIp(conn, def, cur, ctxt);
- else {
- virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("interface miss dhcp or ip adressing"));
- ret = -1;
- }
- }
+ dhcp = virXPathNode(conn, "./dhcp", ctxt);
+ if (dhcp != NULL)
+ ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt);
+
+ if (ret != 0)
+ return(ret);
+
+ ip = virXPathNode(conn, "./ip", ctxt);
+ if (ip != NULL)
+ ret = virInterfaceDefParseIp(conn, def, ip, ctxt);
return(ret);
}
virBufferAddLit(buf, " <dhcp peerdns='yes'/>\n");
else
virBufferAddLit(buf, " <dhcp/>\n");
- } else {
- /* theorically if we don't have dhcp we should have an address */
- if (def->proto.address != NULL) {
- if (def->proto.prefix != 0)
- virBufferVSprintf(buf, " <ip address='%s' prefix='%d'/>\n",
- def->proto.address, def->proto.prefix);
- else
- virBufferVSprintf(buf, " <ip address='%s'/>\n",
- def->proto.address);
- }
- if (def->proto.gateway != NULL) {
- virBufferVSprintf(buf, " <route gateway='%s'/>\n",
- def->proto.gateway);
- }
+ }
+ if (def->proto.address != NULL) {
+ if (def->proto.prefix != 0)
+ virBufferVSprintf(buf, " <ip address='%s' prefix='%d'/>\n",
+ def->proto.address, def->proto.prefix);
+ else
+ virBufferVSprintf(buf, " <ip address='%s'/>\n",
+ def->proto.address);
+ }
+ if (def->proto.gateway != NULL) {
+ virBufferVSprintf(buf, " <route gateway='%s'/>\n",
+ def->proto.gateway);
}
virBufferAddLit(buf, " </protocol>\n");
return(0);
}
static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
- unsigned int flags ATTRIBUTE_UNUSED)
+ unsigned int flags)
{
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
struct netcf_if *iface = NULL;
goto cleanup;
}
- xmlstr = ncf_if_xml_desc(iface);
+ if ((flags & VIR_INTERFACE_XML_INACTIVE)) {
+ xmlstr = ncf_if_xml_desc(iface);
+ } else {
+ xmlstr = ncf_if_xml_state(iface);
+ }
if (!xmlstr) {
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
/**
* virInterfaceGetXMLDesc:
* @iface: an interface object
- * @flags: an OR'ed set of extraction flags, not used yet
+ * @flags: an OR'ed set of extraction flags. Current valid bits:
+ *
+ * VIR_INTERFACE_XML_INACTIVE - return the static configuration,
+ * suitable for use redefining the
+ * interface via virInterfaceDefineXML()
*
- * Provide an XML description of the interface. The description may be reused
- * later to redefine the interface with virInterfaceDefineXML().
+ * Provide an XML description of the interface. If
+ * VIR_INTERFACE_XML_INACTIVE is set, the description may be reused
+ * later to redefine the interface with virInterfaceDefineXML(). If it
+ * is not set, the ip address and netmask will be the current live
+ * setting of the interface, not the settings from the config files.
*
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
* the caller must free() the returned value.
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (NULL);
}
- if (flags != 0) {
+ if ((flags & ~VIR_INTERFACE_XML_INACTIVE) != 0) {
virLibInterfaceError(iface, VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
char *doc = NULL;
char *doc_edited = NULL;
char *doc_reread = NULL;
- int flags = 0;
+ int flags = VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
goto cleanup;
static const vshCmdOptDef opts_interface_dumpxml[] = {
{"interface", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("interface name or MAC address")},
+ {"inactive", VSH_OT_BOOL, 0, gettext_noop("show inactive defined XML")},
{NULL, 0, 0, NULL}
};
virInterfacePtr iface;
int ret = TRUE;
char *dump;
+ int flags = 0;
+ int inactive = vshCommandOptBool(cmd, "inactive");
+
+ if (inactive)
+ flags |= VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
return FALSE;
- dump = virInterfaceGetXMLDesc(iface, 0);
+ dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
printf("%s", dump);
free(dump);