[libvirt] [PATCH 0/4] RFC: vcpupin: some improvements of virsh vcpupin command
by Taku Izumi
Hi all,
This patchset improves virsh vcpupin command like the following:
(i) introduce special markup "-" and "^" which are similar to XML schema
of "cpuset" attribute
# virsh vcpupin VM 0 0-8,^4 --config
# virsh dumpxml VM
...
<vcpu>4</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='0-3,5-8'/>
</cputune>
...
(ii) allow to receive the special keyword 'r' as a cpulist parameter
when resetting vcpupin setting.
# virsh vcpupin VM 0 r --config
(iii) when resetting, that is, pinning the specified virtual cpu to
all host physical cpus, vcpupin setting will be deleted
# virsh dumpxml VM
...
<vcpu>4</vcpu>
<cputune>
</cputune>
...
The following my patchset is the prerequisite of this:
http://www.redhat.com/archives/libvir-list/2011-June/msg00390.html
*[PATCH 1/4] vcpupin: improve vcpupin definition of virsh vcpupin
*[PATCH 2/4] vcpupin: add reset option to virsh vcpupin command
*[PATCH 3/4] vcpupin: add virDomainVcpupinDel function
*[PATCH 4/4] vcpupin: add vcpupin resetting feature to qemu driver
Best regards,
Taku Izumi
13 years, 5 months
[libvirt] [PATCH v4 0/4] vcpupin: configure inactive domain's CPU affinity setting
by Taku Izumi
Hi all,
This patchset enables us to configure inactive domains' CPU affinity
setting.
This is the rebased version, but retains the version number.
*[PATCH v4 1/4] vcpupin: introduce a new libvirt API
(virDomainPinVcpuFlags)
*[PATCH v4 2/4] vcpupin: implement the code to address the new API in the
qemu driver
*[PATCH v4 3/4] vcpupin: implement the remote protocol to address the new
API
*[PATCH v4 4/4] vcpupin: add the new option to "virsh vcpupin" command
Best regards,
Taku Izumi
13 years, 5 months
[libvirt] Driver development
by Carlos N. A. Corrêa
Hi,
I'm interested in developing a new network driver for libvirt (one for the
definition and management of OpenVSwitch datapaths).
I've read some of the code already, and by now my general directions are:
- Change the function virNetworkDefParseXML in src/conf/network_conf.c to
define and parse new configuration directives needed by my driver
- Use src/network/bridge_driver.c as a template for my new driver, replacing
code from the services provided by the driver (listed on "virNetworkDriver"
type) with my own code, for my own net type.
Have you any other directions in this matter? Any tips? If it works, would
be this code of any use to you?
Best regards,
Carlos "Bill" Nilton
CISSP, RHCE, ITIL Foundations
http://carlosnilton.com.br/
13 years, 5 months
[libvirt] [RFC PATCH] Set and reset MAC for PASSTHROUGH mode
by D. Herrendoerfer
Hi to all,
there is a problem present in libvirt that when a PASSTHROUGH mode
DIRECT
NIC connection is made the MAC address of the NIC is not automatically
set
and reset to the configured VM MAC and back again.
The attached patch fixes this problem by setting and resetting the MAC
while remembering the previous setting while the VM is running.
This also works if libvirtd is restarted while the VM is running.
The storing of the previous MAC address is done in a link ( currently
in /tmp,
but should probably go into /var/run somewhere ).
Why a link ? It only uses one inode, no need to waste a whole data block
for 16 bytes or less. It's also more readable by simply looking at it
with 'ls -l'.
Best regards
Dirk
Signed-off-by: Dirk Herrendoerfer <d.herrendoerfer at
herrendoerfer.name>
diff --git a/src/libvirt_macvtap.syms b/src/libvirt_macvtap.syms
index b48565b..0520cb5 100644
--- a/src/libvirt_macvtap.syms
+++ b/src/libvirt_macvtap.syms
@@ -6,5 +6,7 @@
# macvtap.h
delMacvtap;
openMacvtapTap;
+get_macaddr;
+set_macaddr;
vpAssociatePortProfileId;
vpDisassociatePortProfileId;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ef2d002..4cddbba 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -118,6 +118,7 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
int rc;
#if WITH_MACVTAP
char *res_ifname = NULL;
+ unsigned char old_macaddr[6];
int vnet_hdr = 0;
int err;
@@ -125,6 +126,53 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
net->model && STREQ(net->model, "virtio"))
vnet_hdr = 1;
+ /** Note: When using PASSTHROUGH mode with MACVTAP devices the link
+ * devices's MAC address must be set to the VMs MAC address. In
+ * order to not confuse the first switch or bridge in line this MAC
+ * address must be reset when the VM is shut down.
+ * This is especially important when using SRIOV capable cards that
+ * emulate their switch in firmware.
+ */
+ if ( net->data.direct.mode ==
VIR_DOMAIN_NETDEV_MACVTAP_MODE_PASSTHRU ) {
+ rc = get_macaddr(&old_macaddr, 6, net->data.direct.linkdev);
+ if (rc) {
+ virReportSystemError(rc,
+ _("Getting MAC address from '%s' "
+ "to '%02x:%02x:%02x:%02x:%02x:%02x'
failed."),
+ net->data.direct.linkdev,
+
old_macaddr[0],old_macaddr[1],old_macaddr[2],
+
old_macaddr[3],old_macaddr[4],old_macaddr[5]);
+ } else {
+ char oldmacname[256], newmacname[256];
+
+ sprintf(oldmacname,"%02x:%02x:%02x:%02x:%02x:%02x",
+ old_macaddr[0],old_macaddr[1],old_macaddr[2],
+ old_macaddr[3],old_macaddr[4],old_macaddr[5]);
+
+ sprintf(newmacname,"/tmp/%s@%02x:%02x:%02x:%02x:%02x:%02x",
+ net->data.direct.linkdev,
+ net->mac[0],net->mac[1],net->mac[2],
+ net->mac[3],net->mac[4],net->mac[5]);
+
+ rc = symlink (oldmacname, newmacname);
+ if (rc) {
+ virReportSystemError(rc,
+ _("MAC link file creation failed
for %s."),
+ net->data.direct.linkdev);
+ }
+ }
+
+ rc = set_macaddr(net->mac, 6, net->data.direct.linkdev);
+ if (rc) {
+ virReportSystemError(rc,
+ _("Setting MAC address on '%s' to "
+ "'%02x:%02x:%02x:%02x:%02x:%02x'
failed."),
+ net->data.direct.linkdev,
+ net->mac[0],net->mac[1],net->mac[2],
+ net->mac[3],net->mac[4],net->mac[5]);
+ }
+ }
+
rc = openMacvtapTap(net->ifname, net->mac, net-
>data.direct.linkdev,
net->data.direct.mode, vnet_hdr, def->uuid,
&net->data.direct.virtPortProfile,
&res_ifname,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1efe024..127acb8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2663,6 +2663,51 @@ void qemuProcessStop(struct qemud_driver *driver,
if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
delMacvtap(net->ifname, net->mac, net-
>data.direct.linkdev,
&net->data.direct.virtPortProfile);
+
+ if ( net->data.direct.mode ==
VIR_DOMAIN_NETDEV_MACVTAP_MODE_PASSTHRU ) {
+ char newmacname[256], linkdata[64];
+ unsigned int old_macaddr[6];
+
+ sprintf(newmacname,"/tmp/%s@%02x:%02x:%02x:%02x:%02x:
%02x",
+ net->data.direct.linkdev,
+ net->mac[0],net->mac[1],net->mac[2],
+ net->mac[3],net->mac[4],net->mac[5]);
+
+ ret = readlink (newmacname, linkdata, 64);
+ if ( ret == 17 ) {
+ linkdata[17] = 0;
+
+ ret = sscanf(linkdata,"%x:%x:%x:%x:%x:%x",
+
&old_macaddr[0],&old_macaddr[1],&old_macaddr[2],
+
&old_macaddr[3],&old_macaddr[4],&old_macaddr[5]);
+ if ( ret == 6 ) {
+ unsigned char oldmac[6];
+ oldmac[0] = (unsigned char)(old_macaddr[0] & 0xFF) ;
+ oldmac[1] = (unsigned char)(old_macaddr[1] & 0xFF) ;
+ oldmac[2] = (unsigned char)(old_macaddr[2] & 0xFF) ;
+ oldmac[3] = (unsigned char)(old_macaddr[3] & 0xFF) ;
+ oldmac[4] = (unsigned char)(old_macaddr[4] & 0xFF) ;
+ oldmac[5] = (unsigned char)(old_macaddr[5] & 0xFF) ;
+
+ VIR_WARN(("Resetting MAC address on '%s' "
+ "to '%02x:%02x:%02x:%02x:%02x:
%02x'."),
+ net->data.direct.linkdev,
+ oldmac[0],oldmac[1],oldmac[2],
+ oldmac[3],oldmac[4],oldmac[5]);
+ /*reset mac and remove link file-ignore
restults*/
+ ret = set_macaddr(oldmac, 6, net-
>data.direct.linkdev);
+ ret = unlink(newmacname);
+ } else {
+ VIR_WARN(("Scanning MAC address from '%s' "
+ "failed ! Got %i values."),
+ linkdata, ret);
+ }
+ } else {
+ VIR_WARN(("Reading MAC address from '%s' failed ! "
+ "Got %i bytes."),
+ newmacname, ret);
+ }
+ }
VIR_FREE(net->ifname);
}
}
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 068638e..1026a84 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -191,6 +191,155 @@ err_exit:
# if WITH_MACVTAP
+/**
+ * get_macaddr:
+ * Get the MAC address of a network device
+ *
+ * @macaddress: Pointer where the MAC address will be stored
+ * @macaddrsize: Size of the MAC address.
+ * @srcdev: The interface name of the NIC to get the MAC from
+ *
+ * Returns zero in case of success,
+ * negative value otherwise with error reported.
+ *
+ */
+int
+get_macaddr(const unsigned char *macaddress, int macaddrsize,
+ const char *srcdev )
+{
+ int sockfd;
+ int io;
+ char buffer[1024];
+ struct ifreq ifr;
+
+ strcpy(ifr.ifr_name, srcdev);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if(sockfd < 0){
+ return -1;
+ }
+
+ io = ioctl(sockfd, SIOCGIFHWADDR, (char *)&ifr);
+ if(io < 0){
+ return -1;
+ }
+
+ bcopy( ifr.ifr_ifru.ifru_hwaddr.sa_data, macaddress, macaddrsize);
+
+ return 0;
+}
+
+/**
+ * Set_macaddr:
+ * Set the MAC address of a network device
+ *
+ * @macaddress: MAC address to assign to the NIC
+ * @macaddrsize: Size of the MAC address.
+ * @srcdev: The interface name of the NIC
+ *
+ * Returns zero in case of success,
+ * negative value otherwise with error reported.
+ *
+ */
+int
+set_macaddr(const unsigned char *macaddress, int macaddrsize,
+ const char *srcdev )
+{
+ int rc = 0;
+ struct nlmsghdr *resp;
+ struct nlmsgerr *err;
+ struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
+ int ifindex;
+ unsigned char *recvbuf = NULL;
+ unsigned int recvbuflen;
+ struct nl_msg *nl_msg;
+ struct nlattr *linkinfo;
+
+ if (ifaceGetIndex(true, srcdev, &ifindex) != 0)
+ return -1;
+
+ nl_msg = nlmsg_alloc_simple(RTM_SETLINK, NLM_F_REQUEST);
+
+ if (!nl_msg) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO)
< 0)
+ goto buffer_too_small;
+
+ if (nla_put_u32(nl_msg, IFLA_LINK, ifindex) < 0)
+ goto buffer_too_small;
+
+ if (nla_put(nl_msg, IFLA_ADDRESS, macaddrsize, macaddress) < 0)
+ goto buffer_too_small;
+
+ if (srcdev &&
+ nla_put(nl_msg, IFLA_IFNAME, strlen(srcdev)+1, srcdev) < 0)
+ goto buffer_too_small;
+
+ if (nlComm(nl_msg, &recvbuf, &recvbuflen, 0) < 0) {
+ rc = -1;
+ goto err_exit;
+ }
+
+ if (recvbuflen < NLMSG_LENGTH(0) || recvbuf == NULL)
+ goto malformed_resp;
+
+ resp = (struct nlmsghdr *)recvbuf;
+
+ switch (resp->nlmsg_type) {
+ case NLMSG_ERROR:
+ err = (struct nlmsgerr *)NLMSG_DATA(resp);
+ if (resp->nlmsg_len < NLMSG_LENGTH(sizeof(*err)))
+ goto malformed_resp;
+
+ switch (err->error) {
+
+ case 0:
+ break;
+
+ case -EEXIST:
+ rc = -1;
+ break;
+
+ default:
+ macvtapError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("error setting device mac address"));
+ rc = -1;
+ }
+ break;
+
+ case NLMSG_DONE:
+ break;
+
+ default:
+ goto malformed_resp;
+ }
+
+err_exit:
+ nlmsg_free(nl_msg);
+
+ VIR_FREE(recvbuf);
+
+ return rc;
+
+malformed_resp:
+ nlmsg_free(nl_msg);
+
+ macvtapError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("malformed netlink response message"));
+ VIR_FREE(recvbuf);
+ return -1;
+
+buffer_too_small:
+ nlmsg_free(nl_msg);
+
+ macvtapError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("allocated netlink buffer is too small"));
+ return -1;
+}
+
static int
link_add(const char *type,
const unsigned char *macaddress, int macaddrsize,
diff --git a/src/util/macvtap.h b/src/util/macvtap.h
index a1383c4..d71546a 100644
--- a/src/util/macvtap.h
+++ b/src/util/macvtap.h
@@ -75,6 +75,12 @@ enum virVMOperationType {
# include "internal.h"
+int get_macaddr(const unsigned char *macaddress, int macaddrsize,
+ const char *srcdev );
+
+int set_macaddr(const unsigned char *macaddress, int macaddrsize,
+ const char *srcdev );
+
int openMacvtapTap(const char *ifname,
const unsigned char *macaddress,
const char *linkdev,
13 years, 5 months
[libvirt] [PATCH] virt-aa-helper: add missing include
by Eric Blake
Regression introduced in commit 02e8691.
* src/security/virt-aa-helper.c (includes): Reflect move of virRun.
---
Pushing under the build-breaker rule, for Ubuntu.
src/security/virt-aa-helper.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 41ba4a3..afc0d33 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -31,6 +31,7 @@
#include "buf.h"
#include "util.h"
#include "memory.h"
+#include "command.h"
#include "security_driver.h"
#include "security_apparmor.h"
--
1.7.4.4
13 years, 5 months
[libvirt] [libvirt-php][PATCH] screenshot of remote host is available
by warp.kawada@gmail.com
screenshot of remote host is available.
get_domain_object make so many error to message log, so you had better not
use .
diff --git a/examples/libvirt.php b/examples/libvirt.php
index 1ca71b6..bf903f6 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -29,9 +29,9 @@
}
function domain_get_screenshot($domain) {
- $dom = $this->get_domain_object($domain);
-
- $tmp = libvirt_domain_get_screenshot($dom);
+ $dom = libvirt_domain_lookup_by_uuid_string($this->conn, $domain);
+ $hostname = $this->get_hostname();
+ $tmp = libvirt_domain_get_screenshot($dom, $hostname);
return ($tmp) ? $tmp : $this->_set_last_error();
}
diff --git a/src/libvirt-php.cb/src/libvirt-php.c
index 87e0467..4a53e33 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1880,6 +1880,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
int port = -1;
int scancode = 10;
char *path;
+ char *hostname;
path = get_feature_binary("screenshot");
if (access(path, X_OK) != 0) {
@@ -1887,7 +1888,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
RETURN_FALSE;
}
- GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &scancode);
+ GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &hostname, &scancode);
xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
@@ -1912,10 +1913,16 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
RETURN_FALSE;
if (childpid == 0) {
+ char *prm = NULL;
char tmpp[8] = { 0 };
-
+
snprintf(tmpp, sizeof(tmpp), ":%d", port);
- retval = execlp(path, basename(path), tmpp, file, NULL);
+ prm = emalloc((sizeof(tmpp) + sizeof(hostname)) * sizeof(char));
+ sprintf(prm, "%s%s", hostname, tmpp);
+
+ retval = execlp(path, basename(path), prm, file, NULL);
+
+ free(prm);
_exit( retval );
}
else {
13 years, 5 months
[libvirt] [libvirt-php] Work on ./example
by David Streibl
Hello,
as part of my student project I am working on simple web interface which
would support multiple virtualisation platforms.
This of course led me to libvirt and libvirt-php more specificly.
Right now I'm using modfied code of exapme Libvirt class and the plan is:
- add phpdoc
- refactor it to match libvirt convetion (get_domain_someting ->
dmain_get_something)
- split Libvirt to subclasses for domain, connection, network, storage (not
completly sure if it is good idea)
- add few unit tests (dont know about time and usefulness of this)
Would it be welcomed if I send to whole think or even parts of it as patches
to libvirt-php/example?
Thanks for any reply and sorry for my english,
David
13 years, 5 months
[libvirt] [PATCH] build: Fix typos in configure.ac
by Osier Yang
---
configure.ac | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5307a1d..7982e21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1705,9 +1705,9 @@ if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
AC_DEFINE_UNQUOTED([PVCREATE],["$PVCREATE"],[Location of pvcreate program])
AC_DEFINE_UNQUOTED([VGCREATE],["$VGCREATE"],[Location of vgcreate program])
AC_DEFINE_UNQUOTED([LVCREATE],["$LVCREATE"],[Location of lvcreate program])
- AC_DEFINE_UNQUOTED([PVREMOVE],["$PVREMOVE"],[Location of pvcreate program])
- AC_DEFINE_UNQUOTED([VGREMOVE],["$VGREMOVE"],[Location of vgcreate program])
- AC_DEFINE_UNQUOTED([LVREMOVE],["$LVREMOVE"],[Location of lvcreate program])
+ AC_DEFINE_UNQUOTED([PVREMOVE],["$PVREMOVE"],[Location of pvremove program])
+ AC_DEFINE_UNQUOTED([VGREMOVE],["$VGREMOVE"],[Location of vgremove program])
+ AC_DEFINE_UNQUOTED([LVREMOVE],["$LVREMOVE"],[Location of lvremove program])
AC_DEFINE_UNQUOTED([VGCHANGE],["$VGCHANGE"],[Location of vgchange program])
AC_DEFINE_UNQUOTED([VGSCAN],["$VGSCAN"],[Location of vgscan program])
AC_DEFINE_UNQUOTED([PVS],["$PVS"],[Location of pvs program])
--
1.7.4
13 years, 5 months
[libvirt] [PATCH] virsh: Expose virDomainMigrateSetMaxSpeed API to virsh
by Osier Yang
API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but
no command in virsh yet.
---
tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 5 +++++
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index d98be1c..ab83ba9 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4301,6 +4301,50 @@ done:
}
/*
+ * "migrate-setspeed" command
+ */
+static const vshCmdInfo info_migrate_setspeed[] = {
+ {"help", N_("Set the maximum migration bandwidth")},
+ {"desc", N_("Set the maximum migration bandwidth (in Mbps) for a domain "
+ "which is being migrated to another host.")},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_migrate_setspeed[] = {
+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
+ {"bandwidth", VSH_OT_INT, VSH_OFLAG_REQ, N_("migration bandwidth limit in Mbps")},
+ {NULL, 0, 0, NULL}
+};
+
+static bool
+cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom = NULL;
+ unsigned long bandwidth = 0;
+ bool ret = false;
+
+ if (!vshConnectionUsability(ctl, ctl->conn))
+ return false;
+
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (vshCommandOptUL(cmd, "bandwidth", &bandwidth) < 0) {
+ vshError(ctl, "%s", _("migrate: Invalid bandwidth"));
+ goto done;
+ }
+
+ if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0)
+ goto done;
+
+ ret = true;
+
+done:
+ virDomainFree(dom);
+ return ret;
+}
+
+/*
* "net-autostart" command
*/
static const vshCmdInfo info_network_autostart[] = {
@@ -11080,6 +11124,8 @@ static const vshCmdDef domManagementCmds[] = {
{"migrate", cmdMigrate, opts_migrate, info_migrate, 0},
{"migrate-setmaxdowntime", cmdMigrateSetMaxDowntime,
opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime, 0},
+ {"migrate-setspeed", cmdMigrateSetMaxSpeed,
+ opts_migrate_setspeed, info_migrate_setspeed, 0},
{"reboot", cmdReboot, opts_reboot, info_reboot, 0},
{"restore", cmdRestore, opts_restore, info_restore, 0},
{"resume", cmdResume, opts_resume, info_resume, 0},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7ed3003..98adc90 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -542,6 +542,11 @@ Set maximum tolerable downtime for a domain which is being live-migrated to
another host. The I<downtime> is a number of milliseconds the guest is allowed
to be down at the end of live migration.
+=item B<migrate-setspeed> I<domain-id> I<bandwidth>
+
+Set the maximum migration bandwidth (in Mbps) for a domain which is being
+migrated to another host.
+
=item B<reboot> I<domain-id>
Reboot a domain. This acts just as if the domain had the B<reboot>
--
1.7.4
13 years, 5 months
Re: [libvirt] [Qemu-devel] [PATCH 6/9] net: Improve layout of 'info network'
by Anthony Liguori
On 06/07/2011 11:45 AM, Jan Kiszka wrote:
> Improve the layout when listing non-vlan clients via 'info network'. The
> result looks like this:
>
> (qemu) info network
> Devices not on any VLAN:
> orphan: net=10.0.2.0, restricted=n
> virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:56
> \ network2: fd=5
> e1000.0: model=e1000,macaddr=52:54:00:12:34:57
> \ network1: net=10.0.2.0, restricted=n
> rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:58
>
> ie. peers are grouped, orphans are listed as before.
>
> CC: Markus Armbruster<armbru(a)redhat.com>
> Signed-off-by: Jan Kiszka<jan.kiszka(a)siemens.com>
There isn't a query-network yet in QMP so libvirt is probably still
using the HMP version.
Can someone on the libvirt side Ack/Nack about whether this patch will
break libvirt?
Regards,
Anthony Liguori
> ---
> net.c | 14 +++++++++-----
> 1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/net.c b/net.c
> index 4f777c3..606ce70 100644
> --- a/net.c
> +++ b/net.c
> @@ -1224,7 +1224,8 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
> void do_info_network(Monitor *mon)
> {
> VLANState *vlan;
> - VLANClientState *vc;
> + VLANClientState *vc, *peer;
> + net_client_type type;
>
> QTAILQ_FOREACH(vlan,&vlans, next) {
> monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
> @@ -1235,11 +1236,14 @@ void do_info_network(Monitor *mon)
> }
> monitor_printf(mon, "Devices not on any VLAN:\n");
> QTAILQ_FOREACH(vc,&non_vlan_clients, next) {
> - monitor_printf(mon, " %s: %s", vc->name, vc->info_str);
> - if (vc->peer) {
> - monitor_printf(mon, " peer=%s", vc->peer->name);
> + peer = vc->peer;
> + type = vc->info->type;
> + if (!peer || type == NET_CLIENT_TYPE_NIC) {
> + monitor_printf(mon, " %s: %s\n", vc->name, vc->info_str);
> + }
> + if (peer&& type == NET_CLIENT_TYPE_NIC) {
> + monitor_printf(mon, " \\ %s: %s\n", peer->name, peer->info_str);
> }
> - monitor_printf(mon, "\n");
> }
> }
>
13 years, 5 months