[libvirt] boot.kernel.org support in libvirt
by Itamar Reis Peixoto
Hello guy's
what you think to add bko support in libvirt/virt-manager
for example
boot from hard disk
boot from network / pxe
boot from kernel.org
please look -->
http://boot.kernel.org/
--
------------
Itamar Reis Peixoto
e-mail/msn: itamar(a)ispbrasil.com.br
sip: itamar(a)ispbrasil.com.br
skype: itamarjp
icq: 81053601
+55 11 4063 5033
+55 34 3221 8599
15 years, 1 month
Re: [libvirt] Xen: Domain.migrate() causes invalid listDomains() output
by Thomas Treutner
On Wednesday 07 October 2009 10:25:11 Thomas Treutner wrote:
> Shall I provide more debug output?
Here the debug output of libvirtd:
http://tt.scripty.at/tmp/node01.txt.gz
http://tt.scripty.at/tmp/node02.txt.gz
At start, domain wp01 is @ node01, and
wp02 @ node02. Then their placement is exchanged.
After migration:
node01:~# xm list
Name ID Mem VCPUs State
Time(s)
Domain-0 0 256 2 r----- 37.9
wp02 2 512 2 -b---- 0.9
node02:~# xm list
Name ID Mem VCPUs State
Time(s)
Domain-0 0 192 2 r----- 52.4
wp01 3 512 2 -b---- 1.0
virt-top etc. don't see wp01@node02 anymore. libvirt obviously returns ID 1
for it, which can't be resolved. As there is no alternative to
int[] listDomains() (f.e., return UUIDs), I'm stuck here.
NB: Doing migration with xm migrate works fine, libvirt isn't confused by
that.
-t-
15 years, 1 month
[libvirt] cann't connect kvm hypervisor
by Liu, Zhentao
Hello,
I have used virsh to connect my hypervisor, what is the reason?
-------------------------------------------------------------------------------
root@forest:/# virsh -c qemu:///system list
error: unable to connect to '/var/run/libvirt/libvirt-sock': Connection refused
error: failed to connect to the hypervisor
---------------------------------------------------------------------------------
Thanks
Zhentao Liu
15 years, 1 month
[libvirt] [PATCH] Support for IPv6 / multiple ifaces in interface_conf.[ch]
by Laine Stump
This patch updates the xml parsing and formatting, and the associated
virInterfaceDef data structure to support IPv6, along the way adding
support for multiple protocols per interface, and multiple IP
addresses per protocol.
Note that netcf appears to not accept defining both ipv4 and ipv6 on
the same interface, and still can't report live config of IPv6 (or
multiple IPv4 addresses), so the usefulness of this patch is limited
until those items are fixed in netcf.
This patch applies on top of commit
1ceabc5a152efa8892954cb4f45b85553edfee9f, which I submitted on Sept 28.
---
src/conf/interface_conf.c | 308 ++++++++++++++++++++++++++++++++++-----------
src/conf/interface_conf.h | 21 +++-
2 files changed, 247 insertions(+), 82 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index b422464..24f111c 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -53,9 +53,32 @@ void virInterfaceBareDefFree(virInterfaceBareDefPtr def) {
VIR_FREE(def);
}
+static
+void virInterfaceIpDefFree(virInterfaceIpDefPtr def) {
+ if (def == NULL)
+ return;
+ VIR_FREE(def->address);
+ VIR_FREE(def->source);
+}
+
+static
+void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) {
+ int ii;
+
+ if (def == NULL)
+ return;
+ for (ii = 0; ii < def->nips; ii++) {
+ virInterfaceIpDefFree(def->ips[ii]);
+ }
+ VIR_FREE(def->ips);
+ VIR_FREE(def->family);
+ VIR_FREE(def->gateway);
+ VIR_FREE(def);
+}
+
void virInterfaceDefFree(virInterfaceDefPtr def)
{
- int i;
+ int i, pp;
if (def == NULL)
return;
@@ -89,11 +112,11 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
break;
}
- VIR_FREE(def->proto.family);
- VIR_FREE(def->proto.address);
- VIR_FREE(def->proto.gateway);
- VIR_FREE(def->proto.source);
-
+ /* free all protos */
+ for (pp = 0; pp < def->nprotos; pp++) {
+ virInterfaceProtocolDefFree(def->protos[pp]);
+ }
+ VIR_FREE(def->protos);
VIR_FREE(def);
}
@@ -226,22 +249,22 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) {
}
static int
-virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceDefPtr def,
+virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def,
xmlNodePtr dhcp, xmlXPathContextPtr ctxt) {
xmlNodePtr save;
char *tmp;
int ret = 0;
- def->proto.dhcp = 1;
+ def->dhcp = 1;
save = ctxt->node;
ctxt->node = dhcp;
/* Not much to do in the current version */
tmp = virXPathString(conn, "string(./@peerdns)", ctxt);
if (tmp) {
if (STREQ(tmp, "yes"))
- def->proto.peerdns = 1;
+ def->peerdns = 1;
else if (STREQ(tmp, "no"))
- def->proto.peerdns = 0;
+ def->peerdns = 0;
else {
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
_("unknown dhcp peerdns value %s"), tmp);
@@ -249,88 +272,209 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceDefPtr def,
}
VIR_FREE(tmp);
} else
- def->proto.peerdns = -1;
+ def->peerdns = -1;
ctxt->node = save;
return(ret);
}
static int
-virInterfaceDefParseIp(virConnectPtr conn, virInterfaceDefPtr def,
- xmlNodePtr ip ATTRIBUTE_UNUSED, xmlXPathContextPtr ctxt) {
+virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def,
+ xmlXPathContextPtr ctxt) {
int ret = 0;
char *tmp;
long l;
- tmp = virXPathString(conn, "string(./ip[1]/@address)", ctxt);
- def->proto.address = tmp;
+ tmp = virXPathString(conn, "string(./@address)", ctxt);
+ def->address = tmp;
if (tmp != NULL) {
- ret = virXPathLong(conn, "string(./ip[1]/@prefix)", ctxt, &l);
+ ret = virXPathLong(conn, "string(./@prefix)", ctxt, &l);
if (ret == 0)
- def->proto.prefix = (int) l;
+ def->prefix = (int) l;
else if (ret == -2) {
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
"%s", _("Invalid ip address prefix value"));
return(-1);
}
- tmp = virXPathString(conn, "string(./ip[1]/@source)", ctxt);
- def->proto.source = tmp;
+ tmp = virXPathString(conn, "string(./@source)", ctxt);
+ def->source = tmp;
}
- tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt);
- def->proto.gateway = tmp;
return(0);
}
static int
-virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceDefPtr def,
+virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def,
xmlXPathContextPtr ctxt) {
- xmlNodePtr dhcp, ip;
- int ret = 0;
+ xmlNodePtr dhcp;
+ xmlNodePtr *ipNodes = NULL;
+ int nIpNodes, ii, ret = 0;
+ char *tmp;
+
+ tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt);
+ def->gateway = tmp;
dhcp = virXPathNode(conn, "./dhcp", ctxt);
if (dhcp != NULL)
ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt);
+ if (ret != 0)
+ return(ret);
+
+ nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes);
+ if (ipNodes == NULL)
+ return 0;
+
+ if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
+ virReportOOMError(conn);
+ ret = -1;
+ goto error;
+ }
+
+ def->nips = 0;
+ for (ii = 0; ii < nIpNodes; ii++) {
+ virInterfaceIpDefPtr ip;
+
+ if (VIR_ALLOC(ip) < 0) {
+ virReportOOMError(conn);
+ break;
+ }
+
+ ctxt->node = ipNodes[ii];
+ ret = virInterfaceDefParseIp(conn, ip, ctxt);
+ if (ret != 0) {
+ virInterfaceIpDefFree(ip);
+ break;
+ }
+ def->ips[def->nips++] = ip;
+ }
+
+error:
+ VIR_FREE(ipNodes);
+ return(ret);
+}
+
+static int
+virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def,
+ xmlXPathContextPtr ctxt) {
+ xmlNodePtr dhcp, autoconf;
+ xmlNodePtr *ipNodes = NULL;
+ int nIpNodes, ii, ret = 0;
+ char *tmp;
+
+ tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt);
+ def->gateway = tmp;
+
+ autoconf = virXPathNode(conn, "./autoconf", ctxt);
+ if (autoconf != NULL)
+ def->autoconf = 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);
+ nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes);
+ if (ipNodes == NULL)
+ return 0;
+
+ if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
+ virReportOOMError(conn);
+ ret = -1;
+ goto error;
+ }
+
+ def->nips = 0;
+ for (ii = 0; ii < nIpNodes; ii++) {
+
+ virInterfaceIpDefPtr ip;
+
+ if (VIR_ALLOC(ip) < 0) {
+ virReportOOMError(conn);
+ break;
+ }
+
+ ctxt->node = ipNodes[ii];
+ ret = virInterfaceDefParseIp(conn, ip, ctxt);
+ if (ret != 0) {
+ virInterfaceIpDefFree(ip);
+ break;
+ }
+ def->ips[def->nips++] = ip;
+ }
+
+error:
+ VIR_FREE(ipNodes);
return(ret);
}
static int
virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def,
xmlXPathContextPtr ctxt) {
- xmlNodePtr cur, save;
- int ret;
+ xmlNodePtr save;
+ xmlNodePtr *protoNodes = NULL;
+ int nProtoNodes, pp, ret = 0;
char *tmp;
- cur = virXPathNode(conn, "./protocol[1]", ctxt);
- if (cur == NULL)
- return(0);
save = ctxt->node;
- ctxt->node = cur;
- tmp = virXPathString(conn, "string(./@family)", ctxt);
- if (tmp == NULL) {
- virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("protocol misses the family attribute"));
- ret = -1;
- goto done;
+
+ nProtoNodes = virXPathNodeSet(conn, "./protocol", ctxt, &protoNodes);
+ if (nProtoNodes <= 0) {
+ /* no protocols is an acceptable outcome */
+ return 0;
}
- if (STREQ(tmp, "ipv4")) {
- def->proto.family = tmp;
- ret = virInterfaceDefParseProtoIPv4(conn, def, ctxt);
- } else {
- virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- _("unsupported protocol family '%s'"), tmp);
+
+ if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0) {
+ virReportOOMError(conn);
ret = -1;
- VIR_FREE(tmp);
+ goto error;
}
-done:
+ def->nprotos = 0;
+ for (pp = 0; pp < nProtoNodes; pp++) {
+
+ virInterfaceProtocolDefPtr proto;
+
+ if (VIR_ALLOC(proto) < 0) {
+ virReportOOMError(conn);
+ break;
+ }
+
+ ctxt->node = protoNodes[pp];
+ tmp = virXPathString(conn, "string(./@family)", ctxt);
+ if (tmp == NULL) {
+ virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("protocol misses the family attribute"));
+ virInterfaceProtocolDefFree(proto);
+ ret = -1;
+ break;
+ }
+ proto->family = tmp;
+ if (STREQ(tmp, "ipv4")) {
+ ret = virInterfaceDefParseProtoIPv4(conn, proto, ctxt);
+ if (ret != 0) {
+ virInterfaceProtocolDefFree(proto);
+ break;
+ }
+ } else if (STREQ(tmp, "ipv6")) {
+ ret = virInterfaceDefParseProtoIPv6(conn, proto, ctxt);
+ if (ret != 0) {
+ virInterfaceProtocolDefFree(proto);
+ break;
+ }
+ } else {
+ virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
+ _("unsupported protocol family '%s'"), tmp);
+ ret = -1;
+ virInterfaceProtocolDefFree(proto);
+ break;
+ }
+ def->protos[def->nprotos++] = proto;
+ }
+
+error:
+ VIR_FREE(protoNodes);
ctxt->node = save;
return(ret);
@@ -1005,36 +1149,48 @@ virInterfaceVlanDefFormat(virConnectPtr conn, virBufferPtr buf,
static int
virInterfaceProtocolDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED,
virBufferPtr buf, const virInterfaceDefPtr def) {
- char prefixStr[16];
- if (def->proto.family == NULL)
- return(0);
- virBufferVSprintf(buf, " <protocol family='%s'>\n", def->proto.family);
- if (def->proto.dhcp) {
- if (def->proto.peerdns == 0)
- virBufferAddLit(buf, " <dhcp peerdns='no'/>\n");
- else if (def->proto.peerdns == 1)
- virBufferAddLit(buf, " <dhcp peerdns='yes'/>\n");
- else
- virBufferAddLit(buf, " <dhcp/>\n");
- }
- if (def->proto.address != NULL) {
- if (def->proto.prefix != 0)
- snprintf(prefixStr, sizeof(prefixStr), "%d", def->proto.prefix);
-
- virBufferVSprintf(buf, " <ip address='%s'%s%s%s%s%s%s/>\n",
- def->proto.address,
- def->proto.prefix ? " prefix='" : "",
- def->proto.prefix ? prefixStr : "",
- def->proto.prefix ? "'" : "",
- def->proto.source ? " source='" : "",
- def->proto.source ? def->proto.source : "",
- def->proto.source ? "'" : "");
- }
- if (def->proto.gateway != NULL) {
- virBufferVSprintf(buf, " <route gateway='%s'/>\n",
- def->proto.gateway);
+ int pp, ii;
+
+ for (pp = 0; pp < def->nprotos; pp++) {
+
+ virBufferVSprintf(buf, " <protocol family='%s'>\n", def->protos[pp]->family);
+
+ if (def->protos[pp]->autoconf) {
+ virBufferAddLit(buf, " <autoconf/>\n");
+ }
+
+ if (def->protos[pp]->dhcp) {
+ if (def->protos[pp]->peerdns == 0)
+ virBufferAddLit(buf, " <dhcp peerdns='no'/>\n");
+ else if (def->protos[pp]->peerdns == 1)
+ virBufferAddLit(buf, " <dhcp peerdns='yes'/>\n");
+ else
+ virBufferAddLit(buf, " <dhcp/>\n");
+ }
+
+ for (ii = 0; ii < def->protos[pp]->nips; ii++) {
+ if (def->protos[pp]->ips[ii]->address != NULL) {
+
+ virBufferVSprintf(buf, " <ip address='%s'",
+ def->protos[pp]->ips[ii]->address);
+ if (def->protos[pp]->ips[ii]->prefix != 0) {
+ virBufferVSprintf(buf, " prefix='%d'",
+ def->protos[pp]->ips[ii]->prefix);
+ }
+ if (def->protos[pp]->ips[ii]->source != NULL) {
+ virBufferVSprintf(buf, " source='%s'",
+ def->protos[pp]->ips[ii]->source);
+ }
+ virBufferAddLit(buf, "/>\n");
+ }
+ }
+ if (def->protos[pp]->gateway != NULL) {
+ virBufferVSprintf(buf, " <route gateway='%s'/>\n",
+ def->protos[pp]->gateway);
+ }
+
+ virBufferAddLit(buf, " </protocol>\n");
}
- virBufferAddLit(buf, " </protocol>\n");
return(0);
}
diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
index df871aa..49acdd6 100644
--- a/src/conf/interface_conf.h
+++ b/src/conf/interface_conf.h
@@ -123,16 +123,25 @@ struct _virInterfaceVlanDef {
char *devname; /* device name for vlan */
};
+typedef struct _virInterfaceIpDef virInterfaceIpDef;
+typedef virInterfaceIpDef *virInterfaceIpDefPtr;
+struct _virInterfaceIpDef {
+ char *address; /* ip address */
+ int prefix; /* ip prefix */
+ char *source; /* source of address - "device" or "config" (default) */
+};
+
+
typedef struct _virInterfaceProtocolDef virInterfaceProtocolDef;
typedef virInterfaceProtocolDef *virInterfaceProtocolDefPtr;
struct _virInterfaceProtocolDef {
- char *family; /* ipv4 only right now */
+ char *family; /* ipv4 or ipv6 */
int dhcp; /* use dhcp */
int peerdns; /* dhcp peerdns ? */
- char *address; /* ip address */
- int prefix; /* ip prefix */
+ int autoconf; /* only useful if family is ipv6 */
+ int nips;
+ virInterfaceIpDefPtr *ips; /* ptr to array of ips[nips] */
char *gateway; /* route gateway */
- char *source; /* source of address - "device" or "config" (default) */
};
@@ -152,8 +161,8 @@ struct _virInterfaceDef {
virInterfaceBondDef bond;
} data;
- /* separated as we may allow multiple of those in the future */
- virInterfaceProtocolDef proto;
+ int nprotos;
+ virInterfaceProtocolDefPtr *protos; /* ptr to array of protos[nprotos] */
};
typedef struct _virInterfaceObj virInterfaceObj;
--
1.6.2.5
15 years, 1 month
[libvirt] [PATCH] Support reporting live interface IP/netmask.
by Laine Stump
From: root <root(a)vlap.laine.org>
This patch adds the flag VIR_INTERFACE_XML_INACTIVE to
virInterfaceGetXMLDesc's flags. When it is *not* set (the default),
the live interface info will be returned in the XML. in particular,
the IP address(es) and netmask(s) will be retrieved by querying the
device directly, rather than just reporting what's in the config
file. The backend of this is in netcf's new ncf_if_xml_state()
function.
Any live interface ip address info in the xml will have the property
"source" set to "device", eg:
<ip address='10.24.0.1' prefix='24' source='device'/>
Also, if an interface is currently inactive, no ip addresses will be
returned, since an inactive interface device can't be queried for IP
addresses (effectively it has none).
A difference in the XML from previously - it is now acceptable to have
both a dhcp *and* an ip node (or neither) within the protocol
node. Before you had to have one or the other, but couldn't have both.
Note that you need at least netcf 0.1.2 for this to build and work,
and an upcoming release (patches submitted today) for it to work
exactly as described above.
---
include/libvirt/libvirt.h.in | 4 +++
src/conf/interface_conf.c | 62 ++++++++++++++++++++++-------------------
src/conf/interface_conf.h | 1 +
src/interface/netcf_driver.c | 8 ++++-
src/libvirt.c | 15 +++++++---
tools/virsh.c | 10 +++++-
6 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 4e63e48..fd0c90b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -922,6 +922,10 @@ virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
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,
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index e646351..b422464 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -92,6 +92,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
VIR_FREE(def->proto.family);
VIR_FREE(def->proto.address);
VIR_FREE(def->proto.gateway);
+ VIR_FREE(def->proto.source);
VIR_FREE(def);
}
@@ -272,6 +273,8 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceDefPtr def,
"%s", _("Invalid ip address prefix value"));
return(-1);
}
+ tmp = virXPathString(conn, "string(./ip[1]/@source)", ctxt);
+ def->proto.source = tmp;
}
tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt);
def->proto.gateway = tmp;
@@ -282,22 +285,19 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceDefPtr def,
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);
}
@@ -1005,6 +1005,7 @@ virInterfaceVlanDefFormat(virConnectPtr conn, virBufferPtr buf,
static int
virInterfaceProtocolDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED,
virBufferPtr buf, const virInterfaceDefPtr def) {
+ char prefixStr[16];
if (def->proto.family == NULL)
return(0);
virBufferVSprintf(buf, " <protocol family='%s'>\n", def->proto.family);
@@ -1015,20 +1016,23 @@ virInterfaceProtocolDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED,
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)
+ snprintf(prefixStr, sizeof(prefixStr), "%d", def->proto.prefix);
+
+ virBufferVSprintf(buf, " <ip address='%s'%s%s%s%s%s%s/>\n",
+ def->proto.address,
+ def->proto.prefix ? " prefix='" : "",
+ def->proto.prefix ? prefixStr : "",
+ def->proto.prefix ? "'" : "",
+ def->proto.source ? " source='" : "",
+ def->proto.source ? def->proto.source : "",
+ def->proto.source ? "'" : "");
+ }
+ if (def->proto.gateway != NULL) {
+ virBufferVSprintf(buf, " <route gateway='%s'/>\n",
+ def->proto.gateway);
}
virBufferAddLit(buf, " </protocol>\n");
return(0);
diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
index bb9dce4..df871aa 100644
--- a/src/conf/interface_conf.h
+++ b/src/conf/interface_conf.h
@@ -132,6 +132,7 @@ struct _virInterfaceProtocolDef {
char *address; /* ip address */
int prefix; /* ip prefix */
char *gateway; /* route gateway */
+ char *source; /* source of address - "device" or "config" (default) */
};
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index ca14fb0..b5c3664 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -326,7 +326,7 @@ cleanup:
}
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;
@@ -342,7 +342,11 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
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);
diff --git a/src/libvirt.c b/src/libvirt.c
index bcb89e1..bd712dc 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5915,10 +5915,17 @@ virInterfaceGetMACString(virInterfacePtr iface)
/**
* 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.
@@ -5935,7 +5942,7 @@ virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
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;
}
diff --git a/tools/virsh.c b/tools/virsh.c
index 3482389..77f1d70 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2763,7 +2763,7 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
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;
@@ -3297,6 +3297,7 @@ static const vshCmdInfo info_interface_dumpxml[] = {
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}
};
@@ -3306,6 +3307,11 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
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;
@@ -3313,7 +3319,7 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
return FALSE;
- dump = virInterfaceGetXMLDesc(iface, 0);
+ dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
printf("%s", dump);
free(dump);
--
1.6.2.5
15 years, 1 month
[libvirt] [RFC] Multi-IQN proposal
by Shyam_Iyer@Dell.com
Would this proposal be acceptable ?
Example XML schema for an iSCSI storage pool created --
<pool type="iscsi">
<name>dell</name>
<uuid>cf354733-b01b-8870-2040-94888640e24d</uuid>
<capacity>0</capacity>
<allocation>0</allocation>
<available>0</available>
- <source>
<initiator iqnname = "<initiator IQN1>">
<initiator iqnname = "<initiator IQN2>">
........................................
........................................
<host name="<iSCSI target hostname or Target IP address>" />
<device path="<iSCSI Target IQN name>" />
</source>
- <target>
<path>/dev/disk/by-path</path>
- <permissions>
<mode>0700</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</pool>
Each initiator iqn name can be parsed to create the unique sessions.
This should solve the following possibilities --
* possibility of multiple IQNs for a single Guest
* option for Guest's own BIOS & initiator to use these IQNs (iSCSI in
Guest)
* option for hypervisor's initiator to use these IQNs on behalf of the
guest
(Multi-IQN)
Compile tested only. Needs beatification.
diff --git a/src/storage_conf.c b/src/storage_conf.c
index cb063cc..915e897 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -116,6 +116,7 @@ enum {
VIR_STORAGE_POOL_SOURCE_DIR = (1<<2),
VIR_STORAGE_POOL_SOURCE_ADAPTER = (1<<3),
VIR_STORAGE_POOL_SOURCE_NAME = (1<<4),
+ VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN = (1<<5),
};
@@ -537,6 +538,33 @@ virStoragePoolDefParseXML(virConnectPtr conn,
goto cleanup;
}
}
+
+/* Read the conf here */
+ if (options->flags & VIR_STORAGE_POOL_SOURCE_INITATOR_IQN) {
+ int niqn, i;
+
+ if ((niqn = virXPathNodeSet(conn, "./source/host/initiator",
ctxt, &nodeset)) < 0) {
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("cannot extract storage pool source
devices"));
+ goto cleanup;
+ }
+ if (VIR_ALLOC_N(ret->source.niqn, niqn) < 0) {
+ VIR_FREE(nodeset);
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+ for (i = 0 ; i < niqn ; i++ ) {
+ xmlChar *name = xmlGetProp(nodeset[i], BAD_CAST "iqnname");
+ if (path == NULL) {
+ VIR_FREE(nodeset);
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("missing storage pool source device
path"));
+ goto cleanup;
+ }
+ ret->source.initiator[i].iqnname = (char *)name;
+ }
+ }
if (options->flags & VIR_STORAGE_POOL_SOURCE_DEVICE) {
xmlNodePtr *nodeset = NULL;
int nsource, i;
diff --git a/src/storage_conf.h b/src/storage_conf.h
index 421d305..c2504be 100644
--- a/src/storage_conf.h
+++ b/src/storage_conf.h
@@ -202,7 +202,12 @@ struct _virStoragePoolSourceDevice {
} geometry;
};
-
+/* Initiator Attributes */
+typedef virStoragePoolSourceInitiatorAttr
*virStoragePoolSourceInitiatorAttrPtr;
+struct virStoragePoolSourceInitiatorAttr {
+ char *iqnname;
+ /* We could put other initiator specific things here */
+}
typedef struct _virStoragePoolSource virStoragePoolSource;
typedef virStoragePoolSource *virStoragePoolSourcePtr;
@@ -214,6 +219,9 @@ struct _virStoragePoolSource {
int ndevice;
virStoragePoolSourceDevicePtr devices;
+ /*And either one or more initiators*/
+ virStoragePoolSourceInitiatorAttrPtr initiator;
+
/* Or a directory */
char *dir;
15 years, 1 month
[libvirt] [RFC PATCH 0/6] Series short description
by Gerhard Stenzel
The following series of patches is a prototype implementation of a ebtables based MAC address filter. This is currently not intended for inclusion, but rather to get some feedback/comments about the approach and the implementation.
At the moment, some defaults are set when libvirtd starts and when a domain is started or destroyed. The plan is to extend this filter capability to the API level and virsh command level. The plan is also to add more filtering features like VLAN filtering and QoS filtering.
Thanks, Gerhard
---
Gerhard Stenzel (6):
remove currently unused parameter to pass make check test
add MAC address based port filtering to qemu
add MAC address based port filtering to libvirt
add the ebtables wrapper to network driver
add build support for ebtables wrapper
add ebtables wrapper
configure.in | 3
include/libvirt/libvirt.h.in | 14 +
src/Makefile.am | 1
src/conf/network_conf.h | 10
src/driver.h | 14 +
src/libvirt.c | 119 +++++
src/libvirt_private.syms | 26 +
src/libvirt_public.syms | 3
src/network/bridge_driver.c | 175 ++++++++
src/qemu/qemu.conf | 3
src/qemu/qemu_conf.c | 14 +
src/qemu/qemu_conf.h | 2
src/qemu/qemu_driver.c | 23 +
src/test/test_driver.c | 3
src/util/ebtables.c | 961 ++++++++++++++++++++++++++++++++++++++++++
src/util/ebtables.h | 134 ++++++
16 files changed, 1505 insertions(+), 0 deletions(-)
create mode 100644 src/util/ebtables.c
create mode 100644 src/util/ebtables.h
--
15 years, 1 month
[libvirt] Regarding connecting to libvirt from windows
by anuj rampal
Hi,
I can connect to libvirt over TCP/IP from windows and call all the
functions.
what i want is to do some kind of authentication like entering some kind of
username/password.
im using virConnectOpen(const char* name) function.
i tried using virConnectOpenAuth().. but whatever parameter ii give it gets
connected and there is no option to pass username/password.
Thanks in advance.
Regards
Anuj
15 years, 1 month
[libvirt] Creating Guest OS in Virtual Box
by santosh gandham
Hi,
I am trying to create Guest OS (VM) in virtualBox throught libvirt. I
installed libvirt 0.7.0 and created the template as
<domain type='vbox'>
<name>ubuntu</name>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<memory>542720</memory>
<vcpu>1</vcpu>
<devices>
<disk type='file' device='disk'>
<source file='/home/santhosh/Desktop/ubuntu9.vdi'/>
<target dev='hdd'/>
</disk>
<graphics type='rdp' port='3386'/>
</devices>
</domain>
Then I issued this command
$ virsh -c vbox:///session define /home/santhosh/Desktop/ubun.tmpl
Domain ubuntu defined from /home/santhosh/Desktop/ubun.tmpl
When I open VirtualBox, it has created a domain named "ubuntu". All
the parameters specified in the template file are set except "Hard
disks" . So, when I start the VM, I am left with boot errors
00:00:06.318 Guest Log: BIOS: int13_harddisk: function 02, unmapped
device for ELDL=80
00:00:06.319 Guest Log: BIOS: Boot from Hard Disk 0 failed
00:00:06.321 Guest Log: Could not read from the boot medium! System halted.
It is unable to boot from the disk image which I specified in the
template and I am sure the path specified to disk image in the
template is correct.
I am unable to diagnize and find where is the error. Can any one help
me here to know what might be the problem and what should I do.
Thank you.
Best Regards,
Gandham Santhosh
15 years, 1 month