Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-02-23 Thread Laine Stump
On 02/23/2015 08:48 PM, YAMAMOTO Takashi wrote:
>> On Tue, Feb 24, 2015 at 2:20 AM, YAMAMOTO Takashi 
>> wrote:
>>
 Adds the port type definitions and methods that will be used to bind
 interfaces to the Midonet virtual ports.

 virtnetdevmidonet.c adds the way to bind and unbind the ports by
 calling into the Midonet Host Agent control command line (installed
 with the midolman package).

 Signed-off-by: Antoni Segura Puimedon 
>>>
>>> have you considered a script-based solution which would be able
>>> to cover openvswitch case as well?
>>>
>>
>> Can you elaborate? For script I can only think about having an xml node
>> that can be specified for the port type that says what should be run for
>> attachment (like with the ethernet mode). But I'm not sure how it would fit
>> right now.
> 
> i meant to have a "run a script" port type.
> the script runs ovs-vsctl, mm-ctl, or whatever internally.

We actively avoid calling free-form scripts as much as possible. It is
too difficult to support, and opens the possibility of security problems.

For that matter, we even prefer to not call external binaries if we can
avoid it, and eliminate existing executions of external binaries
whenever we get the change. The only reason we agreed to executing
ovs-vsctl is because there is no defined public API for Open vSwitch
that uses a library, netlink message, ioctl, etc. (at least there wasn't
at the time that code was added).

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-02-23 Thread YAMAMOTO Takashi
> On Tue, Feb 24, 2015 at 2:20 AM, YAMAMOTO Takashi 
> wrote:
> 
>> > Adds the port type definitions and methods that will be used to bind
>> > interfaces to the Midonet virtual ports.
>> >
>> > virtnetdevmidonet.c adds the way to bind and unbind the ports by
>> > calling into the Midonet Host Agent control command line (installed
>> > with the midolman package).
>> >
>> > Signed-off-by: Antoni Segura Puimedon 
>>
>> have you considered a script-based solution which would be able
>> to cover openvswitch case as well?
>>
> 
> Can you elaborate? For script I can only think about having an xml node
> that can be specified for the port type that says what should be run for
> attachment (like with the ethernet mode). But I'm not sure how it would fit
> right now.

i meant to have a "run a script" port type.
the script runs ovs-vsctl, mm-ctl, or whatever internally.

YAMAMOTO Takashi

> 
> 
>>
>> YAMAMOTO Takashi

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-02-23 Thread Antoni Segura Puimedon
On Tue, Feb 24, 2015 at 2:20 AM, YAMAMOTO Takashi 
wrote:

> > Adds the port type definitions and methods that will be used to bind
> > interfaces to the Midonet virtual ports.
> >
> > virtnetdevmidonet.c adds the way to bind and unbind the ports by
> > calling into the Midonet Host Agent control command line (installed
> > with the midolman package).
> >
> > Signed-off-by: Antoni Segura Puimedon 
>
> have you considered a script-based solution which would be able
> to cover openvswitch case as well?
>

Can you elaborate? For script I can only think about having an xml node
that can be specified for the port type that says what should be run for
attachment (like with the ethernet mode). But I'm not sure how it would fit
right now.


>
> YAMAMOTO Takashi
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-02-23 Thread YAMAMOTO Takashi
> Adds the port type definitions and methods that will be used to bind
> interfaces to the Midonet virtual ports.
> 
> virtnetdevmidonet.c adds the way to bind and unbind the ports by
> calling into the Midonet Host Agent control command line (installed
> with the midolman package).
> 
> Signed-off-by: Antoni Segura Puimedon 

have you considered a script-based solution which would be able
to cover openvswitch case as well?

YAMAMOTO Takashi

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: don't fill in nicindexes if unneeded

2015-02-23 Thread John Ferlan


On 02/23/2015 03:12 PM, Laine Stump wrote:
> The patch I posted failed to pass make check for two reasons:
> 
> 1) There are valid use cases when the interface object is
> type='ethernet' but has no ifname. Apparently if you provide an "ifup"
> script name for -netdev but don't specify a tap device name, qemu will
> create a tap device for you, and in that case of course libvirt would be
> unable to provide the name to systemd.
> 
> 2) Even if we avoid the code to look for the ifindex when ifname is
> NULL (see (1), make check will *still* fail because there are tests in
> the suite that have type='ethernet' and still have an ifname
> specified, but that device of course doesn't actually exist on the
> test system, so attempts to call virNetDevGetIndex() will
> fail. The solution here is to change qemuBuildInterfaceCommandline()
> so that it won't even try to add anything to the nicindexes array if
> NULL is sent in the args, and modify the calls from test programs to
> do exactly that.
> 
> I intend to squash this patch into the original, already acked by danpb.
> ---
>  src/qemu/qemu_command.c  | 13 ++---
>  src/qemu/qemu_driver.c   |  6 +-
>  tests/qemuxml2argvtest.c |  5 +
>  tests/qemuxmlnstest.c|  5 +
>  4 files changed, 9 insertions(+), 20 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 81f6982..1e63905 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7840,10 +7840,12 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,


Since you're merging anyway...  The comment to the switch needs some
adjustment:

+/* For types whose implementions use a netdev on the host, add an
+ * entry to nicifindexes for passing on to systemd.
+*/

 -> s/implementions/implementations
 -> s/nicifindexes/nicindexes
 -> s/'*/'/' */'/, e.g. needs one extra space to be properly aligned

>  /* network and bridge use a tap device, and direct uses a
>   * macvtap device
>   */
> -   if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
> -   VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
> -  goto cleanup;
> -   break;
> +if (nicindexes && nnicindexes && net->ifname) {

^^ Adding the net->ifname check sets off the Coverity FORWARD_NULL check
later on in the following code

7874if (actualBandwidth) {
7875if (virNetDevSupportBandwidth(actualType)) {
7876if (virNetDevBandwidthSet(net->ifname,
actualBandwidth, false) < 0)

It doesn't seem from some quick testing that we could run into a
situation where net->ifname could be NULL in that second call - one
would have to set bandwidth options... in any case to keep Coverity
happy and perhaps be extra paranoid a "if (net->ifname &&
actualBandwidth)" would avoid the situation.

Beyond that it seems things are fine... So consider it an ACK as long as
you address the Coverity error

John

> +if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
> +VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
> +goto cleanup;
> +}
> +break;
>  }
>  
>  case VIR_DOMAIN_NET_TYPE_USER:
> @@ -8257,9 +8259,6 @@ qemuBuildCommandLine(virConnectPtr conn,
>  
>  virUUIDFormat(def->uuid, uuid);
>  
> -*nnicindexes = 0;
> -*nicindexes = NULL;
> -
>  emulator = def->emulator;
>  
>  if (!cfg->privileged) {
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index bec05d4..04fa8fa 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6447,8 +6447,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr 
> conn,
>  size_t i;
>  virQEMUDriverConfigPtr cfg;
>  virCapsPtr caps = NULL;
> -size_t nnicindexes = 0;
> -int *nicindexes = NULL;
>  
>  virCheckFlags(0, NULL);
>  
> @@ -6634,14 +6632,12 @@ static char 
> *qemuConnectDomainXMLToNative(virConnectPtr conn,
>   &buildCommandLineCallbacks,
>   true,
>   qemuCheckFips(),
> - NULL,
> - &nnicindexes, &nicindexes)))
> + NULL, NULL, NULL)))
>  goto cleanup;
>  
>  ret = virCommandToString(cmd);
>  
>   cleanup:
> -VIR_FREE(nicindexes);
>  virObjectUnref(qemuCaps);
>  virCommandFree(cmd);
>  virDomainDefFree(def);
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 16f325e..7eba5c9 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -263,8 +263,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
>  char *log = NULL;
>  virCommandPtr cmd = NULL;
>  size_t i;
> -size_t nnicindexes = 0;
> -int *nicindexes = NULL;
>  virBitmapPtr nodeset = NULL;
>  
>  if (!(conn = virGetConnect()))
> @@ -355,

Re: [libvirt] [PATCH v3] Add support for Midonet virtual ports

2015-02-23 Thread John Ferlan


On 02/23/2015 03:54 PM, Antoni Segura Puimedon wrote:
> Up until now, to plug VMs into the Midonet virtual networks it was
> necessary to use the 'last resort' 'ethernet' type. That implied
> having the domain tainted and having to deal witht the tap lifecycle
> outside of libvirt/VM lifecycle.
> 
> With the patches I submit, a new virtualport type will be accepted by
> libvirt that will always require an interfaceid (as it is essential
> for binding a tap device to a virtual port that the virtual port
> itself exists and has a UUID). With that interfaceid, libvirt will
> delegate the binding on the Midonet userspace tools.
> 
> Antoni Segura Puimedon (1):
>   Add support for the midonet virtualport type
> 
>  configure.ac |  4 ++
>  docs/schemas/networkcommon.rng   | 12 +
>  src/Makefile.am  |  1 +
>  src/conf/domain_conf.h   |  1 +
>  src/conf/netdev_vport_profile_conf.c |  3 +-
>  src/libvirt_private.syms |  5 ++
>  src/qemu/qemu_hotplug.c  | 25 +++---
>  src/qemu/qemu_process.c  | 13 +++--
>  src/util/virnetdevmidonet.c  | 97 
> 
>  src/util/virnetdevmidonet.h  | 37 ++
>  src/util/virnetdevtap.c  | 11 ++--
>  src/util/virnetdevvportprofile.c |  1 +
>  src/util/virnetdevvportprofile.h |  5 +-
>  13 files changed, 197 insertions(+), 18 deletions(-)
>  create mode 100644 src/util/virnetdevmidonet.c
>  create mode 100644 src/util/virnetdevmidonet.h
> 


You really should resend this as a top level email rather than embedded
as a reply to what was a single patch inside which there already is a v2.

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 4/5] Rename boot_buf to boot_opts

2015-02-23 Thread John Ferlan


On 02/18/2015 11:39 AM, Ján Tomko wrote:
> ---
>  src/qemu/qemu_command.c | 26 +-
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 

ACK

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 5/5] Use virBufferTrim when generating boot options

2015-02-23 Thread John Ferlan


On 02/18/2015 11:39 AM, Ján Tomko wrote:
> Instead of tracking the number of added parameters,
> add a comma at the end of each one unconditionally
> and trim the trailing one at the end.
> ---
>  src/qemu/qemu_command.c | 27 ---
>  1 file changed, 8 insertions(+), 19 deletions(-)
> 

ACK

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/5] Make -boot arg generation more readable

2015-02-23 Thread John Ferlan


On 02/18/2015 11:39 AM, Ján Tomko wrote:
> If we combine the boot order on the command line with other
> boot options, we prepend order= in front of it.
> 
> Instead of checking if the number of added arguments is between
> 0 and 2, separate the buffers for boot order and options
> and prepend boot order only if both buffers are not empty.
> ---
>  src/qemu/qemu_command.c | 37 ++---
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 

ACK - there's a note below which could be implemented or not.

John
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 3658d5f..f13dbda 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8208,6 +8208,8 @@ qemuBuildCommandLine(virConnectPtr conn,
>  virArch hostarch = virArchFromHost();
>  virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
>  virBuffer boot_buf = VIR_BUFFER_INITIALIZER;
> +virBuffer boot_order = VIR_BUFFER_INITIALIZER;
> +char *boot_order_str = NULL, *boot_opts_str = NULL;
>  int boot_nparams = 0;
>  
>  VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
> @@ -8772,10 +8774,12 @@ qemuBuildCommandLine(virConnectPtr conn,
>  }
>  boot[def->os.nBootDevs] = '\0';
>  
> -virBufferAsprintf(&boot_buf, "%s", boot);
> -boot_nparams++;
> +virBufferAsprintf(&boot_order, "%s", boot);
>  }
>  
> +if (virBufferCheckError(&boot_order) < 0)
> +goto error;
> +
^^^
Since the only place to add items is inside the "if (!emitBootindex)",
then this check can move inside the if statement.

Probably could move the other boot_order stuff inside here too including
setting the boot_order_str...

You could then go back to just one boot_buf, but I see in patch 4 & 5
you rename boot_buf... this is fine, just was typing and thinking as
usual...


>  if (def->os.bootmenu) {
>  if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU)) {
>  if (boot_nparams++)

   ^^  This one cannot happen...

Although I see in patch 5 it gets removed anyway...


> @@ -8829,23 +8833,25 @@ qemuBuildCommandLine(virConnectPtr conn,
>  virBufferAddLit(&boot_buf, "strict=on");
>  }
>  
> -if (boot_nparams > 0) {
> -virCommandAddArg(cmd, "-boot");
> +if (virBufferCheckError(&boot_buf) < 0)
> +goto error;
>  
> -if (virBufferCheckError(&boot_buf) < 0)
> -goto error;
> +boot_order_str = virBufferContentAndReset(&boot_order);
> +boot_opts_str = virBufferContentAndReset(&boot_buf);
> +if (boot_order_str || boot_opts_str) {
> +virCommandAddArg(cmd, "-boot");
>  
> -if (boot_nparams < 2 || emitBootindex) {
> -virCommandAddArgBuffer(cmd, &boot_buf);
> -virBufferFreeAndReset(&boot_buf);
> -} else {
> -char *str = virBufferContentAndReset(&boot_buf);
> -virCommandAddArgFormat(cmd,
> -   "order=%s",
> -   str);
> -VIR_FREE(str);
> +if (boot_order_str && boot_opts_str) {
> +virCommandAddArgFormat(cmd, "order=%s,%s",
> +   boot_order_str, boot_opts_str);
> +} else if (boot_order_str) {
> +virCommandAddArg(cmd, boot_order_str);
> +} else if (boot_opts_str) {
> +virCommandAddArg(cmd, boot_opts_str);
>  }
>  }
> +VIR_FREE(boot_order_str);
> +VIR_FREE(boot_opts_str);
>  
>  if (def->os.kernel)
>  virCommandAddArgList(cmd, "-kernel", def->os.kernel, NULL);
> @@ -10335,6 +10341,7 @@ qemuBuildCommandLine(virConnectPtr conn,
>  return cmd;
>  
>   error:
> +virBufferFreeAndReset(&boot_order);
>  virBufferFreeAndReset(&boot_buf);
>  virObjectUnref(cfg);
>  /* free up any resources in the network driver
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] SR-IOV with libvirt

2015-02-23 Thread Laine Stump
On 02/20/2015 05:33 PM, Florin Stingaciu wrote:
> Hello, 
>
> For the last little while I've been trying to configure a VM with a
> passthrough interface using SR-IOV. I've managed to configure SR-IOV
> on the hypervisor correctly. I'm working with a Mellanox ConnectX3
> card with two infiniband ports and hypervisors running Centos 7. I can
> see the PCI devices (ie. virtual functions) using the `virsh
> nodedev-list` command. 
>
> The majority of tutorials online (including the tutorials on the
> libvirt site), suggest one configures an SR-IOV passthrough interface
> in the following manner in the VM definition file:
>
> 
>   
>   
>  function='0x2'/>
>   
>function='0x0'/>
> 
>
> For example the above configuration should configure the second VF as
> a passthrough interface for this VM. When I try to launch the VM, I
> get the following error: 
>
> error: Failed to start domain test
> error: internal error: missing IFLA_VF_INFO in netlink response
>
> I've done research on this error quite extensively. This used to be a
> very popular error a while back for scenarios where the total number
> of VFs is > 64. This is not the case here as I only have 8.  
>
> I've was never able to overcome this error but I did manage to get
> this working another way. The VM will boot just fine and detect a new
> interface if you define one of the VFs as a PCI in the following
> manner within the VM definition file:
>
> 
>   
> 
>   
>function='0x0'/>
>  
>
> As you can see the from the source bus and function, it's the same VF
> I was trying with the definition above. I'm wondering if there is any
> particular reason for this or how could I get around this error.
> Normally, I would just use the second configuration, however I'm about
> to begin work within an openstack environment where the sriovnicswitch
> ml2 plugin will be used for networking. This plugin, when configuring
> passthrough interfaces uses the first definition that does not work
> and spits out that error. 
>
> Considering even the official libvirt tutorials suggest the first way,
> I feel like I must be missing something, or something broke and noone
> noticed in one of the latest updates. Any help would be greatly
> appreciated.
>

No, the problem is with the drivers for the particular cards you are
using. To my understanding, the Mellanox cards have a bit of a different
architecture, and were not initially designed to be SRIOV-compliant (or
maybe they 'comply differently', I'm not sure of the exact details).

I would recommend looking to Mellanox for updated drivers for the card
for CentOS7.

Alternately, you could test it with the RHEL7.1 beta, which will have
newer Mellanox bits than whatever CentOS7 you're currently working with.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv4 02/10] conf: support backend domain name in disk and network devices

2015-02-23 Thread Eric Blake
On 02/19/2015 08:22 PM, Marek Marczykowski-Górecki wrote:
> From: Marek Marczykowski 
> 
> At least Xen supports backend drivers in another domain (aka "driver
> domain"). This patch introduces XML config option for such setting as
> 'domain' attribute of 'source' element. Verification its content is left
> for the driver.
> 
> In the future same option will be needed for USB devices (hostdev
> objects), but for now libxl doesn't have support for PVUSB.
> 
> Signed-off-by: Marek Marczykowski-Górecki 
> ---
> Changes in v2:
>  - describe in docs/formatdomain.html.in
>  - enforce empty domain tag (only 'name' attribute allowed)
> 
> Changes in v3:
>  - change  element to domain='' attribute of source
>element - this is more logical place
>  - grammar of docs
> 
> Changes in v4:
>  - revert back to separate element, named 

Meta-note (don't feel bad about it this time, but food for thought for
future submissions):

It's a little bit easier on reviewers to send a patch series revision
(in this case, v4) as a new top-level thread rather than buried
in-reply-to an existing thread.  For now, that just seems to be an
unwritten convention on libvirt (the qemu project has actually
documented it: http://wiki.qemu.org/Contribute/SubmitAPatch - but their
policies are sometimes stricter than what we require here, so read that
page with a grain of salt). Of course, a patch to libvirt's HACKING to
make it an explicit convention might not hurt :)


-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt-python PATCH 1/2] Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFree

2015-02-23 Thread Eric Blake
On 02/20/2015 12:15 PM, John Ferlan wrote:

> 
> ... Obviously it wasn't very clear to me how the PyList* interactions
> work exactly w/r/t Py_XDECREF - I was trying to copy other uses, but
> didn't do a great job at that.  I was just happy that I got results that
> worked

Don't feel too bad; we have LOTS of bad examples that could use someone
doing a full-blown audit and cleanup.  It's just that it would be
mind-numbing work, that no one seems to want to volunteer for.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Clarify behavior or virDomainDetachDevice

2015-02-23 Thread Eric Blake
On 02/20/2015 04:39 AM, Ján Tomko wrote:
> Doucment that not all attributes are used for matching.

s/Doucment/Document/

> 
> https://bugzilla.redhat.com/show_bug.cgi?id=872028
> ---
>  src/libvirt-domain.c | 5 +
>  tools/virsh.pod  | 4 +++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 

> +++ b/tools/virsh.pod
> @@ -2441,7 +2441,9 @@ the device does not use managed mode.
>  
>  B: using of partial device definition XML files may lead to unexpected
>  results as some fields may be autogenerated and thus match devices other than
> -expected.
> +expected. Not every device attribute is checked when matching the device.
> +For example a network interface can be detatched if the mac and PCI addresses
> +match, even if the type does not.

s/detatched/detached/

(of course, now that I've read the rest of this thread, I see that you
aren't using this wording after all...)

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv2] Clarify behavior or virDomainDetachDevice

2015-02-23 Thread Eric Blake
On 02/20/2015 07:56 AM, Ján Tomko wrote:
> Document that a complete device definition should be used
> and a partial match can lead to the device being detached.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=872028
> ---
>  src/libvirt-domain.c | 14 ++
>  tools/virsh.pod  |  9 ++---
>  2 files changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 492e90a..fb85a28 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -8266,6 +8266,13 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
>   * into S4 state (also known as hibernation) unless you also modify the
>   * persistent domain definition.
>   *
> + * The supplied XML description of the device should be as specific
> + * as its definition in the domain XML. The set of attributes used
> + * to match the device are internal to the drivers. Using a partial 
> definition,
> + * or attempting to detach a device that is not present in the domain XML,
> + * but shares some specific attributes with one that is present

s/present/present,/

> + * may lead to unexpected results.
> + *
>   * Returns 0 in case of success, -1 in case of failure.
>   */
>  int
> @@ -8341,6 +8348,13 @@ virDomainDetachDevice(virDomainPtr domain, const char 
> *xml)
>   * into S4 state (also known as hibernation) unless you also modify the
>   * persistent domain definition.
>   *
> + * The supplied XML description of the device should be as specific
> + * as its definition in the domain XML. The set of attributes used
> + * to match the device are internal to the drivers. Using a partial 
> definition,
> + * or attempting to detach a device that is not present in the domain XML,
> + * but shares some specific attributes with one that is present
> + * may lead to unexpected results.

Here too.

> + *
>   * Returns 0 in case of success, -1 in case of failure.
>   */
>  int
> diff --git a/tools/virsh.pod b/tools/virsh.pod
> index 50de32c..09663f5 100644
> --- a/tools/virsh.pod
> +++ b/tools/virsh.pod
> @@ -2439,9 +2439,12 @@ as command B.
>  For passthrough host devices, see also B, needed if
>  the device does not use managed mode.
>  
> -B: using of partial device definition XML files may lead to unexpected
> -results as some fields may be autogenerated and thus match devices other than
> -expected.
> +B: The supplied XML description of the device should be as specific
> +as its definition in the domain XML. The set of attributes used
> +to match the device are internal to the drivers. Using a partial definition,
> +or attempting to detach a device that is not present in the domain XML,
> +but shares some specific attributes with one that is present
> +may lead to unexpected results.

and here.

ACK with that tweaked.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: Allow spaces in disk serial

2015-02-23 Thread Eric Blake
On 02/23/2015 04:39 AM, Michal Privoznik wrote:
> There's been a bug report appearing on the qemu-devel list, that
> libvirt is unable to pass spaces in disk serial number [1]. Not only
> our RNG schema forbids that, the code is not prepared either. However,
> with a bit of escaping (if needed) we can allow spaces there.
> 
> 1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html
> 
> Signed-off-by: Michal Privoznik 
> ---
>  docs/schemas/domaincommon.rng  |  2 +-
>  src/qemu/qemu_command.c|  5 ++--
>  .../qemuxml2argvdata/qemuxml2argv-disk-serial.args |  6 +
>  .../qemuxml2argvdata/qemuxml2argv-disk-serial.xml  | 27 
> ++
>  tests/qemuxml2argvtest.c   |  5 
>  5 files changed, 42 insertions(+), 3 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
> 

> @@ -3616,7 +3616,8 @@ qemuBuildDriveStr(virConnectPtr conn,
>  virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
>  if (qemuSafeSerialParamValue(disk->serial) < 0)
>  goto error;
> -virBufferAsprintf(&opt, ",serial=%s", disk->serial);
> +virBufferAddLit(&opt, ",serial=");
> +virBufferEscapeShell(&opt, disk->serial);

NACK to this hunk.  We do NOT want shell escaping, because we are NOT
invoking the shell directly.  As proof:

>  }
>  
>  if (disk->cachemode) {
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args 
> b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
> new file mode 100644
> index 000..8b08cfb
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
> @@ -0,0 +1,6 @@
> +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
> QEMU_AUDIO_DRV=none \
> +/usr/libexec/qemu-kvm -S -M pc -cpu qemu32 -m 214 -smp 1 -nographic 
> -nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
> +-drive 'file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1,serial='\''  
> WD-WMAP9A966149'\''' \

your patch is passing the equivalent of serial="'  WD-WMAP9a966149'"
(including the single quotes, which were not present in your XML).  The
log file output will need shell escaping, but we already do that.

Needs a v2.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] Exact meaning of "nativeMode" attribute in vlan tags

2015-02-23 Thread Robson, James
To clarify the behaviour of open vswitch:
With either of the native modes selected, a packet that comes in to the switch 
without a vlan header will be placed in the native vlan and the header added 
before the packet is forwarded.
With nativeMode='tagged', a packet in the native vlan will be sent out of the 
switch with its vlan header intact. With nativeMode='untagged' a packet in the 
native vlan will be sent out of the switch with the vlan header removed.

In case it helps, here is the open vswitch doc for the vlan settings:
 Bridge ports support the following types of VLAN configuration:

  trunk  A  trunk  port  carries packets on one or more specified 
VLANs specified in the trunks column (often, on every VLAN).  A
 packet that ingresses on a trunk port is in the VLAN 
specified in its 802.1Q header, or VLAN 0  if  the  packet  has  no
 802.1Q header.  A packet that egresses through a trunk 
port will have an 802.1Q header if it has a nonzero VLAN ID.

 Any packet that ingresses on a trunk port tagged with a 
VLAN that the port does not trunk is dropped.

  access An  access  port  carries  packets on exactly one VLAN 
specified in the tag column.  Packets egressing on an access port
 have no 802.1Q header.

 Any packet with an 802.1Q header with a nonzero VLAN ID 
that ingresses on an  access  port  is  dropped,  regardless  of
 whether the VLAN ID in the header is the access port’s 
VLAN ID.

  native-tagged
 A native-tagged port resembles a trunk port, with the 
exception that a packet without an 802.1Q header that ingresses on
 a native-tagged port is in the ‘‘native VLAN’’ (specified 
in the tag column).

  native-untagged
 A native-untagged port resembles a native-tagged port, 
with the exception that a  packet  that  egresses  on  a  native-
 untagged port in the native VLAN will not have an 802.1Q 
header.



From: sendmail [justsendmailnothinge...@gmail.com] on behalf of Laine Stump 
[la...@laine.org]
Sent: 22 February 2015 19:31
To: Libvirt
Cc: Robson, James
Subject: Exact meaning of "nativeMode" attribute in vlan tags

You'd think that I would know this, since I'm the person who reviewed
jrobson's patch adding support for the nativeMode attribute to the vlan
tag element. But you'd be wrong. Here is what the config looks like:



  
  


I understand that trunk='yes' means that packets with any of the tags
listed in a  subelement can be sent out this port (and the tag will
*not* be removed), and likewise packets arriving into the bridge from
the port are allowed to have any of the listed tags (and, again, no tag
will be removed). But what exactly do nativeMode='untagged' and
nativeMode='tagged' mean?

As I understand it, (nativeMode='untagged'|nativeMode='tagged') means
that packets (arriving from|sent to) the port (without a tag/with that
tag) will be (tagged|untagged). Can someone who fully understands this
please select A or B for each of the 4 parenthesized items (in as many
permutations as make sense).

I guess that in one of the modes, untagged packets going in one
direction or the other will be tagged, and vice versa, I just don't know
which direction does which, and for which mode, and don't want to guess.

(I'm asking this because I want to implement identical functionality for
standard Linux host bridges - I want to make sure there are no surprises
for people switching between OVS and Linux host bridge implementations).


To report this email as SPAM, please forward it to s...@websense.com


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/3 v3] Schema and docs for the midonet virtualport type

2015-02-23 Thread Antoni Segura Puimedon
Midonet is an opensource virtual networking that over lays the IP
network between hypervisors. Currently, such networks can be made
with the openvswitch virtualport type.

This patch, defines the schema and documentation that will serve
as basis for the follow up patches that will add support to libvirt
for using Midonet virtual ports for its interfaces. The schema
definition requires that the port profile expresses its interfaceid
as part of the port profile. For that reason, this is part of the
patch too.

Signed-off-by: Antoni Segura Puimedon 
---
 docs/formatdomain.html.in  | 34 +
 docs/schemas/networkcommon.rng | 12 
 src/conf/netdev_vport_profile_conf.c   |  3 +-
 .../qemuxml2argvdata/qemuxml2argv-net-midonet.xml  | 35 ++
 tests/qemuxml2xmltest.c|  1 +
 5 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f6477c2..1c2bb45 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3652,6 +3652,40 @@
   
   ...
 
+
+  On hosts that support Open vSwitch on the kernel side and that have the
+  Midonet Host Agent configured, it is also possible to connect to the
+  'midonet' bridge device by adding a
+   to the
+  interface definition.  (Since
+  1.2.13). The Midonet virtualport type requires an
+  interfaceid attribute to its
+   element. This interface id is the UUID
+  that specifies which port in the virtual network topology will be bound
+  to the interface.
+
+
+  ...
+  
+...
+
+  
+
+
+  
+  
+  
+
+
+  
+  
+
+  
+
+...
+  
+  ...
+
 Userspace SLIRP stack
 
 
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 162ea3d..cc8b1dc 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -79,6 +79,18 @@
 
   
   
+
+  
+midonet
+  
+  
+
+  
+
+  
+
+  
+  
 
 
   
diff --git a/src/conf/netdev_vport_profile_conf.c 
b/src/conf/netdev_vport_profile_conf.c
index 8da0838..1641a3e 100644
--- a/src/conf/netdev_vport_profile_conf.c
+++ b/src/conf/netdev_vport_profile_conf.c
@@ -260,7 +260,8 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr 
virtPort,
 virBufferAsprintf(buf, " instanceid='%s'", uuidstr);
 }
 if (virtPort->interfaceID_specified &&
-(type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
+(type == VIR_NETDEV_VPORT_PROFILE_MIDONET ||
+ type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
  type == VIR_NETDEV_VPORT_PROFILE_NONE)) {
 char uuidstr[VIR_UUID_STRING_BUFLEN];
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml
new file mode 100644
index 000..ae5a174
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml
@@ -0,0 +1,35 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+  
+  
+  
+
+
+
+
+
+  
+  
+  
+
+  
+  
+
+
+  
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 99d4629..ba1157c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -275,6 +275,7 @@ mymain(void)
 DO_TEST("net-virtio-network-portgroup");
 DO_TEST("net-hostdev");
 DO_TEST("net-hostdev-vfio");
+DO_TEST("net-midonet");
 DO_TEST("net-openvswitch");
 DO_TEST("sound");
 DO_TEST("sound-device");
-- 
2.3.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3 v3] Add midonet virtual port type support to qemu

2015-02-23 Thread Antoni Segura Puimedon
Use the utilities introduced in the previous patches so the qemu
driver is able to create tap devices that are bound (and unbound
on domain destroyal) to Midonet virtual ports.

Signed-off-by: Antoni Segura Puimedon 
---
 src/conf/domain_conf.h  |  1 +
 src/qemu/qemu_hotplug.c | 25 ++---
 src/qemu/qemu_process.c | 13 +
 src/util/virnetdevtap.c | 11 ---
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 325afa8..cafe50f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -42,6 +42,7 @@
 # include "virnetdevmacvlan.h"
 # include "virsysinfo.h"
 # include "virnetdevvportprofile.h"
+# include "virnetdevmidonet.h"
 # include "virnetdevopenvswitch.h"
 # include "virnetdevbandwidth.h"
 # include "virnetdevvlan.h"
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 8691c7e..34d7988 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1141,9 +1141,15 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
 }
 
 vport = virDomainNetGetActualVirtPortProfile(net);
-if (vport && vport->virtPortType == 
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-   ignore_value(virNetDevOpenvswitchRemovePort(
-   virDomainNetGetActualBridgeName(net), 
net->ifname));
+if (vport) {
+if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+ignore_value(virNetDevMidonetUnbindPort(vport));
+} else if (vport->virtPortType == 
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+ignore_value(virNetDevOpenvswitchRemovePort(
+ virDomainNetGetActualBridgeName(net),
+ net->ifname));
+}
+}
 }
 
 virDomainNetRemoveHostdev(vm->def, net);
@@ -2934,10 +2940,15 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
 }
 
 vport = virDomainNetGetActualVirtPortProfile(net);
-if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-ignore_value(virNetDevOpenvswitchRemovePort(
-virDomainNetGetActualBridgeName(net),
-net->ifname));
+if (vport) {
+if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+ignore_value(virNetDevMidonetUnbindPort(vport));
+} else if (vport->virtPortType == 
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+ignore_value(virNetDevOpenvswitchRemovePort(
+ virDomainNetGetActualBridgeName(net),
+ net->ifname));
+}
+}
 
 networkReleaseActualDevice(vm->def, net);
 virDomainNetDefFree(net);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1d4e957..982f802 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5291,10 +5291,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
 /* release the physical device (or any other resources used by
  * this interface in the network driver
  */
-if (vport && vport->virtPortType == 
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-ignore_value(virNetDevOpenvswitchRemovePort(
-   virDomainNetGetActualBridgeName(net),
-   net->ifname));
+if (vport) {
+if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+ignore_value(virNetDevMidonetUnbindPort(vport));
+} else if (vport->virtPortType == 
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+ignore_value(virNetDevOpenvswitchRemovePort(
+ virDomainNetGetActualBridgeName(net),
+ net->ifname));
+}
+}
 
 /* kick the device out of the hostdev list too */
 virDomainNetRemoveHostdev(def, net);
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 83b4131..f6152e9 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -26,6 +26,7 @@
 #include "virnetdevtap.h"
 #include "virnetdev.h"
 #include "virnetdevbridge.h"
+#include "virnetdevmidonet.h"
 #include "virnetdevopenvswitch.h"
 #include "virerror.h"
 #include "virfile.h"
@@ -580,9 +581,13 @@ int virNetDevTapCreateInBridgePort(const char *brname,
 goto error;
 
 if (virtPortProfile) {
-if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid,
-virtPortProfile, virtVlan) < 0) {
-goto error;
+if (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) 
{
+if (virNetDevMidonetBindPort(*ifname, virtPortProfile) < 0)
+goto error;
+} else {
+if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid,
+   

[libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-02-23 Thread Antoni Segura Puimedon
Adds the port type definitions and methods that will be used to bind
interfaces to the Midonet virtual ports.

virtnetdevmidonet.c adds the way to bind and unbind the ports by
calling into the Midonet Host Agent control command line (installed
with the midolman package).

Signed-off-by: Antoni Segura Puimedon 
---
 configure.ac |  4 ++
 po/POTFILES.in   |  1 +
 src/Makefile.am  |  1 +
 src/libvirt_private.syms |  5 +++
 src/util/virnetdevmidonet.c  | 97 
 src/util/virnetdevmidonet.h  | 37 +++
 src/util/virnetdevvportprofile.c |  3 +-
 src/util/virnetdevvportprofile.h |  3 +-
 8 files changed, 149 insertions(+), 2 deletions(-)
 create mode 100644 src/util/virnetdevmidonet.c
 create mode 100644 src/util/virnetdevmidonet.h

diff --git a/configure.ac b/configure.ac
index b3e99e7..ddffbb2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -425,6 +425,8 @@ AC_PATH_PROG([MODPROBE], [modprobe], [modprobe],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
 AC_PATH_PROG([RMMOD], [rmmod], [rmmod],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
+AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl],
+   [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
 AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
 AC_PATH_PROG([SCRUB], [scrub], [scrub],
@@ -440,6 +442,8 @@ AC_DEFINE_UNQUOTED([RADVD],["$RADVD"],
 [Location or name of the radvd program])
 AC_DEFINE_UNQUOTED([TC],["$TC"],
 [Location or name of the tc program (see iproute2)])
+AC_DEFINE_UNQUOTED([MMCTL],["$MMCTL"],
+[Location or name of the mm-ctl program])
 AC_DEFINE_UNQUOTED([OVSVSCTL],["$OVSVSCTL"],
 [Location or name of the ovs-vsctl program])
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3064037..cdfc839 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -195,6 +195,7 @@ src/util/virnetdev.c
 src/util/virnetdevbandwidth.c
 src/util/virnetdevbridge.c
 src/util/virnetdevmacvlan.c
+src/util/virnetdevmidonet.c
 src/util/virnetdevopenvswitch.c
 src/util/virnetdevtap.c
 src/util/virnetdevveth.c
diff --git a/src/Makefile.am b/src/Makefile.am
index b41c6d4..23d3f93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -129,6 +129,7 @@ UTIL_SOURCES =  
\
util/virnetdevbandwidth.h util/virnetdevbandwidth.c \
util/virnetdevbridge.h util/virnetdevbridge.c   \
util/virnetdevmacvlan.c util/virnetdevmacvlan.h \
+   util/virnetdevmidonet.h util/virnetdevmidonet.c \
util/virnetdevopenvswitch.h util/virnetdevopenvswitch.c \
util/virnetdevtap.h util/virnetdevtap.c \
util/virnetdevveth.h util/virnetdevveth.c   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 46a1613..0938cdc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1738,6 +1738,11 @@ virNetDevMacVLanRestartWithVPortProfile;
 virNetDevMacVLanVPortProfileRegisterCallback;
 
 
+# util/virnetdevmidonet.h
+virNetDevMidonetBindPort;
+virNetDevMidonetUnbindPort;
+
+
 # util/virnetdevopenvswitch.h
 virNetDevOpenvswitchAddPort;
 virNetDevOpenvswitchGetMigrateData;
diff --git a/src/util/virnetdevmidonet.c b/src/util/virnetdevmidonet.c
new file mode 100644
index 000..57fb636
--- /dev/null
+++ b/src/util/virnetdevmidonet.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2015 Midokura, Sarl.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * .
+ *
+ * Authors:
+ * Antoni Segura Puimedon 
+ */
+
+#include 
+
+#include "virnetdevmidonet.h"
+#include "vircommand.h"
+#include "viralloc.h"
+#include "virerror.h"
+#include "viruuid.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+/**
+ * virNetDevMidonetBindPort:
+ * @ifname: the network interface name
+ * @virtualport: the midonet specific fields
+ *
+ * Bind an interface to a Midonet virtual port
+ *
+ * Returns 0 in case of success or -1 in case of failure.
+ */
+int virNetDevMidonetBindPort(const char *ifname,
+virNetDevVPortProfilePtr virtualport)
+{
+int ret = -1;
+virCommandPtr cmd = NULL;
+char virtportuuid[VIR_UUID_STRING_BUFLEN];
+
+virUUIDFormat(virtualport->interfaceID, virtportuuid);
+
+cmd = virCommandNew

[libvirt] [PATCH v3] Add support for Midonet virtual ports

2015-02-23 Thread Antoni Segura Puimedon
Up until now, to plug VMs into the Midonet virtual networks it was
necessary to use the 'last resort' 'ethernet' type. That implied
having the domain tainted and having to deal witht the tap lifecycle
outside of libvirt/VM lifecycle.

With the patches I submit, a new virtualport type will be accepted by
libvirt that will always require an interfaceid (as it is essential
for binding a tap device to a virtual port that the virtual port
itself exists and has a UUID). With that interfaceid, libvirt will
delegate the binding on the Midonet userspace tools.

Antoni Segura Puimedon (1):
  Add support for the midonet virtualport type

 configure.ac |  4 ++
 docs/schemas/networkcommon.rng   | 12 +
 src/Makefile.am  |  1 +
 src/conf/domain_conf.h   |  1 +
 src/conf/netdev_vport_profile_conf.c |  3 +-
 src/libvirt_private.syms |  5 ++
 src/qemu/qemu_hotplug.c  | 25 +++---
 src/qemu/qemu_process.c  | 13 +++--
 src/util/virnetdevmidonet.c  | 97 
 src/util/virnetdevmidonet.h  | 37 ++
 src/util/virnetdevtap.c  | 11 ++--
 src/util/virnetdevvportprofile.c |  1 +
 src/util/virnetdevvportprofile.h |  5 +-
 13 files changed, 197 insertions(+), 18 deletions(-)
 create mode 100644 src/util/virnetdevmidonet.c
 create mode 100644 src/util/virnetdevmidonet.h

-- 
2.3.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/5] Remove code handling the QEMU_CAPS_DOMID capability

2015-02-23 Thread John Ferlan


On 02/18/2015 11:39 AM, Ján Tomko wrote:
> This option is xenner-only, and we dropped support for xenner
> in commit de9be0a.
> ---
>  src/qemu/qemu_command.c  | 5 +
>  tests/qemuxml2argvtest.c | 5 +
>  tests/qemuxmlnstest.c| 5 +
>  3 files changed, 3 insertions(+), 12 deletions(-)
> 

ACK,

John

FWIW: Originally added by 'b81a7ece'

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/5] Remove bootloader option from QEMU

2015-02-23 Thread John Ferlan


On 02/18/2015 11:39 AM, Ján Tomko wrote:
> It was only supported by xenner, for which we removed support in
> commit de9be0a.
> 
> Remove the code generating this command line option,
> refuse to parse it and delete the outdated tests.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1176050
> ---
>  src/qemu/qemu_command.c| 233 
> ++---
>  src/qemu/qemu_domain.c |   6 +
>  .../qemuxml2argvdata/qemuxml2argv-bootloader.args  |   5 -
>  tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml |  27 ---
>  tests/qemuxml2argvdata/qemuxml2argv-input-xen.args |   5 -
>  tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml  |  34 ---
>  tests/qemuxml2argvtest.c   |   2 -
>  tests/qemuxml2xmltest.c|   2 -
>  8 files changed, 120 insertions(+), 194 deletions(-)
>  delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bootloader.args
>  delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml
>  delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
>  delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml
> 

ACK

John

FWIW: Just for completeness... Originally added by commit id '763a59d8'


> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 743d6f0..b522bdc 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8207,6 +8207,8 @@ qemuBuildCommandLine(virConnectPtr conn,
>  };
>  virArch hostarch = virArchFromHost();
>  virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
> +virBuffer boot_buf = VIR_BUFFER_INITIALIZER;
> +int boot_nparams = 0;
>  
>  VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
>"qemuCaps=%p migrateFrom=%s migrateFD=%d "
> @@ -8728,148 +8730,140 @@ qemuBuildCommandLine(virConnectPtr conn,
> def->pm.s4 == VIR_TRISTATE_BOOL_NO);
>  }
>  
> -if (!def->os.bootloader) {
> -int boot_nparams = 0;
> -virBuffer boot_buf = VIR_BUFFER_INITIALIZER;
> -/*
> - * We prefer using explicit bootindex=N parameters for predictable
> - * results even though domain XML doesn't use per device boot 
> elements.
> - * However, we can't use bootindex if boot menu was requested.
> +/*
> + * We prefer using explicit bootindex=N parameters for predictable
> + * results even though domain XML doesn't use per device boot elements.
> + * However, we can't use bootindex if boot menu was requested.
> + */
> +if (!def->os.nBootDevs) {
> +/* def->os.nBootDevs is guaranteed to be > 0 unless per-device boot
> + * configuration is used
>   */
> -if (!def->os.nBootDevs) {
> -/* def->os.nBootDevs is guaranteed to be > 0 unless per-device 
> boot
> - * configuration is used
> - */
> -if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
> -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -   _("hypervisor lacks deviceboot feature"));
> -goto error;
> -}
> -emitBootindex = true;
> -} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
> -   (def->os.bootmenu != VIR_TRISTATE_BOOL_YES ||
> -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) {
> -emitBootindex = true;
> -}
> -
> -if (!emitBootindex) {
> -char boot[VIR_DOMAIN_BOOT_LAST+1];
> -
> -for (i = 0; i < def->os.nBootDevs; i++) {
> -switch (def->os.bootDevs[i]) {
> -case VIR_DOMAIN_BOOT_CDROM:
> -boot[i] = 'd';
> -break;
> -case VIR_DOMAIN_BOOT_FLOPPY:
> -boot[i] = 'a';
> -break;
> -case VIR_DOMAIN_BOOT_DISK:
> -boot[i] = 'c';
> -break;
> -case VIR_DOMAIN_BOOT_NET:
> -boot[i] = 'n';
> -break;
> -default:
> -boot[i] = 'c';
> -break;
> -}
> -}
> -boot[def->os.nBootDevs] = '\0';
> -
> -virBufferAsprintf(&boot_buf, "%s", boot);
> -boot_nparams++;
> +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +   _("hypervisor lacks deviceboot feature"));
> +goto error;
>  }
> +emitBootindex = true;
> +} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
> +   (def->os.bootmenu != VIR_TRISTATE_BOOL_YES ||
> +!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) {
> +emitBootindex = true;
> +}
>  
> -if (def->os.bootmenu) {
> -if (

[libvirt] [PATCH] qemu: don't fill in nicindexes if unneeded

2015-02-23 Thread Laine Stump
The patch I posted failed to pass make check for two reasons:

1) There are valid use cases when the interface object is
type='ethernet' but has no ifname. Apparently if you provide an "ifup"
script name for -netdev but don't specify a tap device name, qemu will
create a tap device for you, and in that case of course libvirt would be
unable to provide the name to systemd.

2) Even if we avoid the code to look for the ifindex when ifname is
NULL (see (1), make check will *still* fail because there are tests in
the suite that have type='ethernet' and still have an ifname
specified, but that device of course doesn't actually exist on the
test system, so attempts to call virNetDevGetIndex() will
fail. The solution here is to change qemuBuildInterfaceCommandline()
so that it won't even try to add anything to the nicindexes array if
NULL is sent in the args, and modify the calls from test programs to
do exactly that.

I intend to squash this patch into the original, already acked by danpb.
---
 src/qemu/qemu_command.c  | 13 ++---
 src/qemu/qemu_driver.c   |  6 +-
 tests/qemuxml2argvtest.c |  5 +
 tests/qemuxmlnstest.c|  5 +
 4 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 81f6982..1e63905 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7840,10 +7840,12 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
 /* network and bridge use a tap device, and direct uses a
  * macvtap device
  */
-   if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
-   VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
-  goto cleanup;
-   break;
+if (nicindexes && nnicindexes && net->ifname) {
+if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
+VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
+goto cleanup;
+}
+break;
 }
 
 case VIR_DOMAIN_NET_TYPE_USER:
@@ -8257,9 +8259,6 @@ qemuBuildCommandLine(virConnectPtr conn,
 
 virUUIDFormat(def->uuid, uuid);
 
-*nnicindexes = 0;
-*nicindexes = NULL;
-
 emulator = def->emulator;
 
 if (!cfg->privileged) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bec05d4..04fa8fa 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6447,8 +6447,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr 
conn,
 size_t i;
 virQEMUDriverConfigPtr cfg;
 virCapsPtr caps = NULL;
-size_t nnicindexes = 0;
-int *nicindexes = NULL;
 
 virCheckFlags(0, NULL);
 
@@ -6634,14 +6632,12 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr 
conn,
  &buildCommandLineCallbacks,
  true,
  qemuCheckFips(),
- NULL,
- &nnicindexes, &nicindexes)))
+ NULL, NULL, NULL)))
 goto cleanup;
 
 ret = virCommandToString(cmd);
 
  cleanup:
-VIR_FREE(nicindexes);
 virObjectUnref(qemuCaps);
 virCommandFree(cmd);
 virDomainDefFree(def);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 16f325e..7eba5c9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -263,8 +263,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
 char *log = NULL;
 virCommandPtr cmd = NULL;
 size_t i;
-size_t nnicindexes = 0;
-int *nicindexes = NULL;
 virBitmapPtr nodeset = NULL;
 
 if (!(conn = virGetConnect()))
@@ -355,7 +353,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
  VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
  &testCallbacks, false,
  (flags & FLAG_FIPS),
- nodeset, &nnicindexes, &nicindexes))) {
+ nodeset, NULL, NULL))) {
 if (!virtTestOOMActive() &&
 (flags & FLAG_EXPECT_FAILURE)) {
 ret = 0;
@@ -402,7 +400,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
 ret = 0;
 
  out:
-VIR_FREE(nicindexes);
 VIR_FREE(log);
 VIR_FREE(expectargv);
 VIR_FREE(actualargv);
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index a068135..4220737 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -44,8 +44,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
 char *log = NULL;
 char *emulator = NULL;
 virCommandPtr cmd = NULL;
-size_t nnicindexes = 0;
-int *nicindexes = NULL;
 
 if (!(conn = virGetConnect()))
 goto fail;
@@ -122,7 +120,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
  migrateFrom, migrateFd, NULL,
  VIR_NETDEV_VPOR

Re: [libvirt] [PATCH 0/3] s390: rework and prevent default usb controller

2015-02-23 Thread John Ferlan


On 02/18/2015 10:44 AM, Stefan Zimmermann wrote:
> 
> Stefan Zimmermann (3):
>   Prevent default creation of usb controller on s390 and s390x
>   Adjust s390 test cases by removing usb device instances
>   Rework s390 architecture checking
> 
>  src/qemu/qemu_command.c |  4 +++-
>  src/qemu/qemu_domain.c  | 13 
> +
>  tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args   |  2 +-
>  .../qemuxml2argv-s390-piix-controllers.args |  2 +-
>  .../qemuxml2xmlout-s390-defaultconsole.xml  |  1 -
>  5 files changed, 14 insertions(+), 8 deletions(-)
> 

ACK - series and pushed, although I combined patch 1 & 2 since we don't
want to break git bisect and patch 2 essentially fixes the tests that
patch 1 will change.

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: bulk stats: implement (cpu) tune group.

2015-02-23 Thread John Ferlan


On 02/11/2015 09:22 AM, Francesco Romani wrote:
> Management applications, like oVirt, may need to setup cpu quota
> limits to enforce QoS for VMs.
> 
> For this purpose, management applications also need to check how
> VMs are behaving with respect to CPU quota. This data is avaialble
> using the virDomainGetSchedulerParameters API.
> 
> This patch adds a new group to bulk stats API to obtain the same
> information.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1191428
> ---
>  include/libvirt/libvirt-domain.h |  1 +
>  src/libvirt-domain.c | 16 
>  src/qemu/qemu_driver.c   | 84 
> 
>  tools/virsh-domain-monitor.c |  7 
>  4 files changed, 108 insertions(+)
> 

In general looks good... There's a few spelling and spacing nits below
which I could fix up before pushing for you...

You are missing 'virsh.pod' - something easily added as well.

The one question I have is around the switch name (looking for any other
thoughts...)

Should the option be "cpu-tune" instead of "tune-cpu", especially since
the name of the function has "*CpuTune"? Or even 'sched-info' to match
the 'virsh schedinfo $dom' command?  I suppose some day there'd be
'numa-tune' data desired as well, but that's a different issue...

John
> diff --git a/include/libvirt/libvirt-domain.h 
> b/include/libvirt/libvirt-domain.h
> index 4dbd7f5..3d8c6af 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -1700,6 +1700,7 @@ typedef enum {
>  VIR_DOMAIN_STATS_VCPU = (1 << 3), /* return domain virtual CPU info */
>  VIR_DOMAIN_STATS_INTERFACE = (1 << 4), /* return domain interfaces info 
> */
>  VIR_DOMAIN_STATS_BLOCK = (1 << 5), /* return domain block info */
> +VIR_DOMAIN_STATS_TUNE_CPU = (1 << 6), /* return domain CPU tuning info */
>  } virDomainStatsTypes;
>  
>  typedef enum {
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 492e90a..a4effa3 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -10990,6 +10990,22 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
>   * "block..physical" - physical size in bytes of the container of the
>   *  backing image as unsigned long long.
>   *
> + * VIR_DOMAIN_STATS_TUNE_CPU: Return CPU tuning statistics
> + * and usage information.
> + * The typed parameter keys are in this format:
> + * "tune.vcpu.quota" - max allowed bandwith, in microseconds, as

s/bandwith/bandwidth

> + * long long integer. -1 means 'infinite'.
> + * "tune.vcpu.period" - timeframe on which the virtual cpu quota is
> + *  enforced, in microseconds, as unsigned long long.
> + * "tune.emu.quota" - max allowd bandwith for emulator threads,

s/bandwith/bandwidth
s/allowd/allowed

> + *in microseconds, as long long integer.
> + *-1 means 'infinite'.
> + * "tune.emu.period" - timeframe on which the emulator quota is
> + * enforced, in microseconds, as unsigned long long.
> + * "tune.cpu.shares" - weight of this VM. This value is meaningful
> + * only if compared with the other values of
> + * the running vms. Expressed as unsigned long long.

s/vms/domains

FWIW: I guess I find it hard to read 'vms' without thinking about the
VMS (or OpenVMS) operating system ;-) [guess where I started my career].

> + *
>   * Note that entire stats groups or individual stat fields may be missing 
> from
>   * the output in case they are not supported by the given hypervisor, are not
>   * applicable for the current state of the guest domain, or their retrieval
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 26fc6a2..5548626 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -18797,6 +18797,89 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
>  
>  #undef QEMU_ADD_COUNT_PARAM
>  
> +
> +#define QEMU_ADD_PARAM_LL(record, maxparams, name, value) \
> +do { \
> +if (virTypedParamsAddLLong(&(record)->params, \
> +   &(record)->nparams, \
> +   maxparams, \
> +   name, \
> +   value) < 0) \
> +goto cleanup; \
> +} while (0)
> +
> +#define QEMU_ADD_PARAM_ULL(record, maxparams, name, value) \
> +do { \
> +if (virTypedParamsAddULLong(&(record)->params, \
> +&(record)->nparams, \
> +maxparams, \
> +name, \
> +value) < 0) \
> +goto cleanup; \
> +} while (0)
> +
> +static int
> +qemuDomainGetStatsCpuTune(virQEMUDriverPtr driver,
> +  virDomainObjPtr dom,
> +  virDomainStatsRecordPtr record,
> +  int *maxparams,
> +  unsign

Re: [libvirt] [PATCH] Add ability to set rlimits at container boot

2015-02-23 Thread Richard Weinberger
Ryan,

Am 23.02.2015 um 18:37 schrieb Ryan Cleere:
> Richard, 
> 
> I have to disagree that it should require idmap. It is true that without 
> idmap the container can freely set it's own rlimits, but I believe this 
> functionality could be useful to
> containers that don't run /sbin/init. What I mean by that is application 
> specific containers could have their limits set without the application 
> having to set them, or even having
> to write a shim to set them. 

Sorry, I don't understand. What has running a non /sbin/init do to with that?
Without user namespaces root within the container can bypass these limits.

Thanks,
//richard

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2] SRIOV NIC offload feature discovery

2015-02-23 Thread James Chapman
Adding functionality to libvirt that will allow it
query the ethtool interface for the availability
of certain NIC HW offload features

Here is an example of the feature XML definition:


net_eth4_90_e2_ba_5e_a5_45
  /sys/devices/pci:00/:00:03.0/:08:00.1/net/eth4
  pci__08_00_1
  
eth4
90:e2:ba:5e:a5:45











  

---
 docs/formatnode.html.in   |  18 +++
 docs/schemas/nodedev.rng  |  14 +++
 src/conf/device_conf.h|   6 +
 src/conf/node_device_conf.c   |  45 ++-
 src/conf/node_device_conf.h   |   2 +
 src/libvirt_private.syms  |   1 +
 src/node_device/node_device_udev.c|   4 +
 src/util/virnetdev.c  | 143 ++
 src/util/virnetdev.h  |   7 ++
 tests/nodedevschemadata/net_00_13_02_b9_f9_d3.xml |   9 ++
 tests/nodedevschemadata/net_00_15_58_2f_e9_55.xml |   9 ++
 11 files changed, 257 insertions(+), 1 deletion(-)

diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index b820a34..ba9a0f8 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -183,6 +183,24 @@
 link. So far, the whole element is just for output,
 not setting.
   
+  feature
+  If present, the hw offloads supported by this network
+interface. Possible features are:
+
+rxrx-checksumming
+txtx-checksumming
+sgscatter-gather
+tsotcp-segmentation-offload
+ufoudp-fragmentation-offload
+
gsogeneric-segmentation-offload
+grogeneric-receive-offload
+lrolarge-receive-offload
+rxvlanrx-vlan-offload
+txvlantx-vlan-offload
+ntuplentuple-filters
+rxhashreceive-hashing
+
+  
   capability
   A network protocol exposed by the device, where the
 attribute type can be "80203" for IEEE
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 13c5402..744dccd 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -275,10 +275,24 @@
 
 
 
+  
+
+  
+
+  
+
+
+
   
 
   
 
+  
+
+  [a-zA-Z\-_]+
+
+  
+
   
 
   
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 7256cdc..091f2f0 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -62,6 +62,12 @@ struct _virInterfaceLink {
 unsigned int speed;  /* link speed in Mbits per second */
 };
 
+typedef struct _virDevFeature virDevFeature;
+typedef virDevFeature *virDevFeaturePtr;
+struct _virDevFeature {
+   char *name; /* device feature */
+};
+
 int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr);
 
 int virDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index a728a00..76b53f0 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -437,6 +437,12 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
 virBufferEscapeString(&buf, "%s\n",
   data->net.address);
 virInterfaceLinkFormat(&buf, &data->net.lnk);
+if (data->net.features) {
+for (i = 0; i < data->net.nfeatures; i++) {
+virBufferAsprintf(&buf, "\n",
+data->net.features[i].name);
+}
+}
 if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
 const char *subtyp =
 virNodeDevNetCapTypeToString(data->net.subtype);
@@ -927,8 +933,10 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
  union _virNodeDevCapData *data)
 {
 xmlNodePtr orignode, lnk;
-int ret = -1;
+size_t i = -1;
+int ret = -1, n = -1;
 char *tmp;
+xmlNodePtr *nodes = NULL;
 
 orignode = ctxt->node;
 ctxt->node = node;
@@ -943,6 +951,38 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
 
 data->net.address = virXPathString("string(./address[1])", ctxt);
 
+if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
+goto out;
+
+if (n > 0) {
+if (VIR_RESIZE_N(data->net.features, data->net.nfeatures, 
data->net.nfeatures, n) < 0)
+goto out;
+data->net.nfeatures = n;
+}
+
+for (i = 0; i < n; i++) {
+char *name;
+size_t j;
+
+if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) {
+VIR_FREE(name);
+virReportError(VIR_ERR_XML_ERROR, "%s",
+  

[libvirt] [PATCH] SRIOV NIC offload feature discovery

2015-02-23 Thread James Chapman
Adding functionality to libvirt that will allow it
query the ethtool interface for the availability
of certain NIC HW offload features

Here is an example of the feature XML definition:


net_eth4_90_e2_ba_5e_a5_45
  /sys/devices/pci:00/:00:03.0/:08:00.1/net/eth4
  pci__08_00_1
  
eth4
90:e2:ba:5e:a5:45











  

---
 docs/formatnode.html.in   |  18 +++
 docs/schemas/nodedev.rng  |  14 +++
 src/conf/device_conf.h|   6 +
 src/conf/node_device_conf.c   |  45 ++-
 src/conf/node_device_conf.h   |   2 +
 src/libvirt_private.syms  |   1 +
 src/node_device/node_device_udev.c|   4 +
 src/util/virnetdev.c  | 143 ++
 src/util/virnetdev.h  |   7 ++
 tests/nodedevschemadata/net_00_13_02_b9_f9_d3.xml |   9 ++
 tests/nodedevschemadata/net_00_15_58_2f_e9_55.xml |   9 ++
 11 files changed, 257 insertions(+), 1 deletion(-)

diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index b820a34..ba9a0f8 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -183,6 +183,24 @@
 link. So far, the whole element is just for output,
 not setting.
   
+  feature
+  If present, the hw offloads supported by this network
+interface. Possible features are:
+
+rxrx-checksumming
+txtx-checksumming
+sgscatter-gather
+tsotcp-segmentation-offload
+ufoudp-fragmentation-offload
+
gsogeneric-segmentation-offload
+grogeneric-receive-offload
+lrolarge-receive-offload
+rxvlanrx-vlan-offload
+txvlantx-vlan-offload
+ntuplentuple-filters
+rxhashreceive-hashing
+
+  
   capability
   A network protocol exposed by the device, where the
 attribute type can be "80203" for IEEE
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 13c5402..744dccd 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -275,10 +275,24 @@
 
 
 
+  
+
+  
+
+  
+
+
+
   
 
   
 
+  
+
+  [a-zA-Z\-_]+
+
+  
+
   
 
   
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 7256cdc..091f2f0 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -62,6 +62,12 @@ struct _virInterfaceLink {
 unsigned int speed;  /* link speed in Mbits per second */
 };
 
+typedef struct _virDevFeature virDevFeature;
+typedef virDevFeature *virDevFeaturePtr;
+struct _virDevFeature {
+   char *name; /* device feature */
+};
+
 int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr);
 
 int virDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index a728a00..76b53f0 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -437,6 +437,12 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
 virBufferEscapeString(&buf, "%s\n",
   data->net.address);
 virInterfaceLinkFormat(&buf, &data->net.lnk);
+if (data->net.features) {
+for (i = 0; i < data->net.nfeatures; i++) {
+virBufferAsprintf(&buf, "\n",
+data->net.features[i].name);
+}
+}
 if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) {
 const char *subtyp =
 virNodeDevNetCapTypeToString(data->net.subtype);
@@ -927,8 +933,10 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
  union _virNodeDevCapData *data)
 {
 xmlNodePtr orignode, lnk;
-int ret = -1;
+size_t i = -1;
+int ret = -1, n = -1;
 char *tmp;
+xmlNodePtr *nodes = NULL;
 
 orignode = ctxt->node;
 ctxt->node = node;
@@ -943,6 +951,38 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
 
 data->net.address = virXPathString("string(./address[1])", ctxt);
 
+if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
+goto out;
+
+if (n > 0) {
+if (VIR_RESIZE_N(data->net.features, data->net.nfeatures, 
data->net.nfeatures, n) < 0)
+goto out;
+data->net.nfeatures = n;
+}
+
+for (i = 0; i < n; i++) {
+char *name;
+size_t j;
+
+if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) {
+VIR_FREE(name);
+virReportError(VIR_ERR_XML_ERROR, "%s",
+  

Re: [libvirt] [PATCH] SRIOV NIC offload feature discovery

2015-02-23 Thread Chapman, James P
Thanks for your feedback folks, v2 to follow.


Thanks
James


-Original Message-
From: Daniel P. Berrange [mailto:berra...@redhat.com] 
Sent: Monday, February 16, 2015 11:47 AM
To: Chapman, James P
Cc: libvir-list@redhat.com
Subject: Re: [libvirt] [PATCH] SRIOV NIC offload feature discovery

On Mon, Feb 16, 2015 at 10:18:32AM +, James Chapman wrote:
> Adding functionality to libvirt that will allow it query the ethtool 
> interface for the availability of certain NIC HW offload features
> ---
>  src/conf/device_conf.h |   6 ++
>  src/conf/node_device_conf.c|   7 ++
>  src/conf/node_device_conf.h|   2 +
>  src/libvirt_private.syms   |   1 +
>  src/node_device/node_device_udev.c |   4 ++
>  src/util/virnetdev.c   | 134 
> +
>  src/util/virnetdev.h   |  12 +++-
>  7 files changed, 165 insertions(+), 1 deletion(-)

If you're modifying the XML parser then you need to also change the XML schema 
(docs/schemas/nodedev.rng), add example XML for testing the schema 
(tests/nodedevschemadata) and finally extend the docs 
(docs/formatnodedev.html.in). Also it is good to include the proposed XML 
change in the commit message for reviewers.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 0/9] qemu: Add quorum support to libvirt

2015-02-23 Thread Matthias Gatto
On Tue, Feb 10, 2015 at 4:43 PM, Matthias Gatto
 wrote:
> The purpose of these patches is to introduce quorum for libvirt
> I've try to follow this proposal:
> http://www.redhat.com/archives/libvir-list/2014-May/msg00533.html
>
> This feature ask for 6 task:
>
> 1) Allow a _virStorageSource to contain more than one backing store.
>
> Because all the actual libvirt code use the backingStore field
> as a pointer and we needs want to change that, I've decide to encapsulate
> the backingStore field to simplifie the array manipulation.
>
> 2) Add the missing field a quorum need in _virStorageSource and
> the VIR_STORAGE_TYPE_QUORUM and VIR_STORAGE_FILE_QUORUM in
> their respectives enums.
>
> 3) Parse and format the xml
> Because a quorum allows to have more than one backing store at the same level
> we need to change virDomainDiskDefFormat and virDomainDiskDefParseXML
> to call virDomainDiskBackingStoreFormat and virDomainDiskBackingStoreParse
> in a loop.
> virDomainDiskBackingStoreFormat and virDomainDiskBackingStoreParse can
> call themself recursively in a loop because a quorum can contain another
> quorum
>
> 4) Add nodename
> We need to add nodename support in _virStorageSource because qemu
> use them for their child.
>
> 5) Build qemu string
> As for the xml, we have to call the function which create quorum recursively.
> But this task have the problem explained here:
> http://www.redhat.com/archives/libvir-list/2014-October/msg00529.html
> The _virStorageSource missing some informations that can be passed to
> a child, and therefore this version of quorum is incomplet.
>
> 6) Allow to hotplug/change a disk in a quorum
> This part is not present in these patches because for this task
> we have to use blockdev-add, and currently libvirt use
> device_add for hotpluging that doesn't allow to hotplug quorum childs.
>
> There is 3 way to handle this problem:
>   1) create a virDomainBlockDevAdd function in libvirt witch call
>   blockdev-add.
>
>   2) use blockdev-add instead of device_add in qemuMonitorJSONAddDevice
>
>   3) write a hack which uses blockdev-add when only attaching quorum
>   (but i'm pretty sure this solution is not the good one)
>
> V2:
> -Rebase on master
> -Add Documentation
>
> V3:
> -Transforme the backingStore field in virStorageSource into
>  an array of pointer instead of a pointer
> -Modify virStorageSourceSetBackingStore to allow it to expand
>  the backingStore size.
>
> Matthias Gatto (9):
>   virstoragefile: Add virStorageSourceGetBackingStore
>   virstoragefile: Always use virStorageSourceGetBackingStore to get
> backing store
>   virstoragefile: Add virStorageSourceSetBackingStore
>   virstoragefile: Always use virStorageSourceSetBackingStore to set
> backing store
>   virstoragefile: change backingStore to backingStores.
>   virstoragefile: Add quorum in virstoragefile
>   domain_conf: Read and Write quorum config
>   qemu: Add quorum support in qemuBuildDriveDevStr
>   virstoragefile: Add node-name
>
>  docs/formatdomain.html.in |  27 -
>  docs/schemas/domaincommon.rng |  96 +++--
>  docs/schemas/storagecommon.rng|   1 +
>  docs/schemas/storagevol.rng   |   1 +
>  src/conf/domain_conf.c| 195 
> ++
>  src/conf/storage_conf.c   |  23 ++--
>  src/libvirt_private.syms  |   2 +
>  src/qemu/qemu_cgroup.c|   4 +-
>  src/qemu/qemu_command.c   | 114 
>  src/qemu/qemu_domain.c|   2 +-
>  src/qemu/qemu_driver.c|  30 +++---
>  src/qemu/qemu_migration.c |   1 +
>  src/security/security_dac.c   |   2 +-
>  src/security/security_selinux.c   |   4 +-
>  src/security/virt-aa-helper.c |   2 +-
>  src/storage/storage_backend.c |  33 +++---
>  src/storage/storage_backend_fs.c  |  36 ---
>  src/storage/storage_backend_gluster.c |  10 +-
>  src/storage/storage_backend_logical.c |  15 ++-
>  src/storage/storage_driver.c  |   2 +-
>  src/util/virstoragefile.c | 116 +---
>  src/util/virstoragefile.h |  12 ++-
>  tests/virstoragetest.c|  18 ++--
>  23 files changed, 573 insertions(+), 173 deletions(-)
>
> --
> 1.8.3.1
>

ping

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2 2/2] Support virDomainSetIOThreads

2015-02-23 Thread John Ferlan
Support the libvirt_virDomainSetIOThreads method using code that mimics
the existing libvirt_virDomainPinVcpuFlags method

The following is a sample session assuming guest 'iothr-gst' has IOThreads
configured (it's currently running, too)

>>> import libvirt
>>> con=libvirt.open("qemu:///system")
>>> dom=con.lookupByName('iothr-gst')
>>> dom.ioThreadsInfo()
[(1, [False, False, True, False], ['/home/vm-images/iothr-vol1']), (2, [False, 
False, False, True], ['/home/vm-images/iothr-vol2']), (3, [False, False, False, 
True], [])]
>>> cpumap=(True,True,True,False)
>>> dom.setIOThreads(3,cpumap)
0
>>> print dom.ioThreadsInfo()
[(1, [False, False, True, False], ['/home/vm-images/iothr-vol1']), (2, [False, 
False, False, True], ['/home/vm-images/iothr-vol2']), (3, [True, True, True, 
False], [])]
>>>

Signed-off-by: John Ferlan 
---
 generator.py |  1 +
 libvirt-override-api.xml |  8 ++
 libvirt-override.c   | 66 
 3 files changed, 75 insertions(+)

diff --git a/generator.py b/generator.py
index 8165a18..aa140ed 100755
--- a/generator.py
+++ b/generator.py
@@ -436,6 +436,7 @@ skip_impl = (
 'virDomainGetEmulatorPinInfo',
 'virDomainPinEmulator',
 'virDomainGetIOThreadsInfo',
+'virDomainSetIOThreads',
 'virSecretGetValue',
 'virSecretSetValue',
 'virSecretGetUUID',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index e512311..19667b6 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -284,6 +284,14 @@
   
   
 
+
+  Dynamically change the real CPUs which can be allocated to an 
IOThread. This function requires privileged access to the hypervisor.
+  
+  
+  
+  
+  
+
 
   Change the scheduler parameters
   
diff --git a/libvirt-override.c b/libvirt-override.c
index 580a1b2..8823a39 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -2100,6 +2100,71 @@ cleanup:
 return error;
 }
 
+static PyObject *
+libvirt_virDomainSetIOThreads(PyObject *self ATTRIBUTE_UNUSED,
+  PyObject *args)
+{
+virDomainPtr domain;
+PyObject *pyobj_domain, *pycpumap;
+PyObject *ret = NULL;
+unsigned char *cpumap;
+int cpumaplen, iothread_val, tuple_size, cpunum;
+size_t i;
+unsigned int flags;
+int i_retval;
+
+if (!PyArg_ParseTuple(args, (char *)"OiOI:virDomainSetIOThread",
+  &pyobj_domain, &iothread_val, &pycpumap, &flags))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
+return VIR_PY_INT_FAIL;
+
+if (PyTuple_Check(pycpumap)) {
+if ((tuple_size = PyTuple_Size(pycpumap)) == -1)
+return ret;
+} else {
+   PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
+   return ret;
+}
+
+cpumaplen = VIR_CPU_MAPLEN(cpunum);
+if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
+return PyErr_NoMemory();
+
+for (i = 0; i < tuple_size; i++) {
+PyObject *flag = PyTuple_GetItem(pycpumap, i);
+bool b;
+
+if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
+goto cleanup;
+
+if (b)
+VIR_USE_CPU(cpumap, i);
+else
+VIR_UNUSE_CPU(cpumap, i);
+}
+
+for (; i < cpunum; i++)
+VIR_UNUSE_CPU(cpumap, i);
+
+flags |= VIR_DOMAIN_IOTHREADS_PIN;
+LIBVIRT_BEGIN_ALLOW_THREADS;
+i_retval = virDomainSetIOThreads(domain, iothread_val,
+ cpumap, cpumaplen, flags);
+LIBVIRT_END_ALLOW_THREADS;
+if (i_retval < 0) {
+ret = VIR_PY_INT_FAIL;
+goto cleanup;
+}
+ret = VIR_PY_INT_SUCCESS;
+
+cleanup:
+VIR_FREE(cpumap);
+return ret;
+}
+
 #endif /* LIBVIR_CHECK_VERSION(1, 2, 13) */
 
 /
@@ -8596,6 +8661,7 @@ static PyMethodDef libvirtMethods[] = {
 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
 #if LIBVIR_CHECK_VERSION(1, 2, 13)
 {(char *) "virDomainGetIOThreadsInfo", libvirt_virDomainGetIOThreadsInfo, 
METH_VARARGS, NULL},
+{(char *) "virDomainSetIOThreads", libvirt_virDomainSetIOThreads, 
METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(1, 2, 13) */
 {(char *) "virConnectListStoragePools", 
libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
 {(char *) "virConnectListDefinedStoragePools", 
libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2 1/2] Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFree

2015-02-23 Thread John Ferlan
Add support for the libvirt_virDomainGetIOThreadsInfo method. This
code mostly follows the libvirt_virDomainGetVcpuPinInfo method, but
also takes some from the libvirt_virNodeGetCPUMap method with respect
to building the cpumap into the returned tuple rather than two separate
tuples which vcpu pinning generates

Assuming two domains, one with IOThreads defined (eg, 'iothr-gst') and
one without ('noiothr-gst'), execute the following in an 'iothr.py' file:

import libvirt
con=libvirt.open("qemu:///system")
dom=con.lookupByName('iothr-gst')
print dom.ioThreadsInfo()
dom2=con.lookupByName('noiothr-gst')
print dom2.ioThreadsInfo()

$ python iothr.py
[(1, [False, False, True, False], ['/home/vm-images/iothr-vol1']), (2, [False, 
False, False, True], ['/home/vm-images/iothr-vol2']), (3, [True, False, False, 
False], [])]
[]
$

Signed-off-by: John Ferlan 
---
 generator.py |   5 +++
 libvirt-override-api.xml |   6 +++
 libvirt-override.c   | 114 +++
 sanitytest.py|   5 +++
 4 files changed, 130 insertions(+)

diff --git a/generator.py b/generator.py
index 0d48980..8165a18 100755
--- a/generator.py
+++ b/generator.py
@@ -435,6 +435,7 @@ skip_impl = (
 'virDomainGetVcpuPinInfo',
 'virDomainGetEmulatorPinInfo',
 'virDomainPinEmulator',
+'virDomainGetIOThreadsInfo',
 'virSecretGetValue',
 'virSecretSetValue',
 'virSecretGetUUID',
@@ -592,6 +593,7 @@ skip_function = (
 'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
 'virDomainStatsRecordListFree', # only useful in C, python uses dict
 'virDomainFSInfoFree', # only useful in C, python code uses list
+'virDomainIOThreadsInfoFree', # only useful in C, python code uses list
 )
 
 lxc_skip_function = (
@@ -1144,6 +1146,9 @@ def nameFixup(name, classe, type, file):
 elif name[0:20] == "virDomainGetCPUStats":
 func = name[9:]
 func = func[0:1].lower() + func[1:]
+elif name[0:25] == "virDomainGetIOThreadsInfo":
+func = name[12:]
+func = func[0:2].lower() + func[2:]
 elif name[0:18] == "virDomainGetFSInfo":
 func = name[12:]
 func = func[0:2].lower() + func[2:]
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 439cb40..e512311 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -278,6 +278,12 @@
   
   
 
+
+  Query the CPU affinity setting of the IOThreads of the 
domain
+  
+  
+  
+
 
   Change the scheduler parameters
   
diff --git a/libvirt-override.c b/libvirt-override.c
index 88cb527..580a1b2 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1990,6 +1990,117 @@ libvirt_virDomainGetEmulatorPinInfo(PyObject *self 
ATTRIBUTE_UNUSED,
 }
 #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
 
+#if LIBVIR_CHECK_VERSION(1, 2, 13)
+static PyObject *
+libvirt_virDomainGetIOThreadsInfo(PyObject *self ATTRIBUTE_UNUSED,
+  PyObject *args) {
+virDomainPtr domain;
+PyObject *pyobj_domain;
+PyObject *py_retval = NULL;
+PyObject *error = NULL;
+virDomainIOThreadsInfoPtr *iothrinfo = NULL;
+unsigned int flags;
+size_t pcpu, i, j;
+int niothreads, cpunum;
+
+if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetIOThreadsInfo",
+  &pyobj_domain, &flags))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
+return VIR_PY_NONE;
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+niothreads = virDomainGetIOThreadsInfo(domain, &iothrinfo, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (niothreads < 0) {
+error = VIR_PY_NONE;
+goto cleanup;
+}
+
+/* convert to a Python list */
+if ((py_retval = PyList_New(niothreads)) == NULL)
+goto cleanup;
+
+/* NOTE: If there are zero IOThreads we will return an empty list */
+for (i = 0; i < niothreads; i++) {
+PyObject *iothrtpl = NULL;
+PyObject *iothrid = NULL;
+PyObject *iothrmap = NULL;
+PyObject *resources = NULL;
+virDomainIOThreadsInfoPtr iothr = iothrinfo[i];
+
+if (iothr == NULL) {
+error = VIR_PY_NONE;
+goto cleanup;
+}
+
+if ((iothrtpl = PyTuple_New(3)) == NULL ||
+PyList_SetItem(py_retval, i, iothrtpl) < 0) {
+Py_XDECREF(iothrtpl);
+goto cleanup;
+}
+
+/* 0: IOThread ID */
+if ((iothrid = libvirt_uintWrap(iothr->iothread_id)) == NULL ||
+PyTuple_SetItem(iothrtpl, 0, iothrid) < 0) {
+Py_XDECREF(iothrid);
+goto cleanup;
+}
+
+/* 1: CPU map */
+if ((iothrmap = PyList_New(cpunum)) == NULL ||
+PyTuple_SetItem(iothrtpl, 1, iothrmap) < 0) {
+Py_XDECREF(iothrmap);
+goto cleanup;
+}
+

[libvirt] [PATCH v2 0/2] Python bindings for IOThreads

2015-02-23 Thread John Ferlan
v1 here:

http://www.redhat.com/archives/libvir-list/2015-February/msg00684.html

Changes in v2:
 * Return an empty list when there are no IOThreads found
 * Fix alloc/cleanup logic to match review comments
   * Used "PyObject *error = NULL" like the GetCPUStats code in order to
 return either NULL for Py*_New() and PyTuple_SetItem() method errors
 or VIR_PY_NONE for other exceptions
   * Only make the Py_XDECREF calls on objects which don't get consumed by
 PyTuple_SetItem 
 * Change name of method from "getIOThreadsInfo" to "ioThreadsInfo"

John Ferlan (2):
  Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFree
  Support virDomainSetIOThreads

 generator.py |   6 ++
 libvirt-override-api.xml |  14 
 libvirt-override.c   | 180 +++
 sanitytest.py|   5 ++
 4 files changed, 205 insertions(+)

-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] network_conf: Forbid commas in DNS TXT

2015-02-23 Thread Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1151942

While the restriction doesn't have origin in any RFC, it matters
to us while constructing the dnsmasq config file (or command line
previously). For better picture, this is how the corresponding
part of network XML look like:

  


  

And this is how the config file looks like then:

  server=8.8.4.4
  txt-record=example,example value

Now we can see why there can't be any commas in the TXT name.
They are used by dnsmasq to separate @name and @value.

Funny, we have it in the documentation, but the code (which was
pushed back in 2011) didn't reflect that.

Signed-off-by: Michal Privoznik 
---
 src/conf/network_conf.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index dce3360..3d8bf05 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1057,15 +1057,17 @@ virNetworkDNSTxtDefParseXML(const char *networkName,
 virNetworkDNSTxtDefPtr def,
 bool partialOkay)
 {
+const char *bad = " ,";
+
 if (!(def->name = virXMLPropString(node, "name"))) {
 virReportError(VIR_ERR_XML_DETAIL,
_("missing required name attribute in DNS TXT record "
  "of network %s"), networkName);
 goto error;
 }
-if (strchr(def->name, ' ') != NULL) {
+if (strcspn(def->name, bad) != strlen(def->name)) {
 virReportError(VIR_ERR_XML_DETAIL,
-   _("prohibited space character in DNS TXT record "
+   _("prohibited character in DNS TXT record "
  "name '%s' of network %s"), def->name, networkName);
 goto error;
 }
-- 
2.0.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] qemu: Pass file descriptor when using TPM passthrough

2015-02-23 Thread Stefan Berger
Pass the TPM file descriptor to QEMU via command line.
Instead of passing /dev/tpm0 we now pass /dev/fdset/10 and the additional
parameters -add-fd set=10,fd=20.

This addresses the use case when QEMU is started with non-root privileges
and QEMU cannot open /dev/tpm0 for example.

Signed-off-by: Stefan Berger 
---
 src/qemu/qemu_command.c | 121 ++--
 1 file changed, 117 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 539c956..12e2e2f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -161,6 +161,58 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST,
   "interleave");
 
 /**
+ * qemuVirCommandGetFDSet:
+ * @cmd: the command to modify
+ * @fd: fd to reassign to the child
+ *
+ * Get the parameters for the QEMU -add-fd command line option
+ * for the given file descriptor. The file descriptor must previously
+ * have been 'transferred' in a virCommandPassFD() call.
+ * This function for example returns "set=10,fd=20".
+ */
+static char *
+qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
+{
+char *result = NULL;
+int idx = virCommandPassFDGetFDIndex(cmd, fd);
+
+if (idx >= 0) {
+ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd) < 0);
+} else {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("file descriptor %d has not been transferred"), fd);
+}
+
+return result;
+}
+
+/**
+ * qemuVirCommandGetDevSet:
+ * @cmd: the command to modify
+ * @fd: fd to reassign to the child
+ *
+ * Get the parameters for the QEMU path= parameter where a file
+ * descriptor is accessed via a file descriptor set, for example
+ * /dev/fdset/10. The file descriptor must previously have been
+ * 'transferred' in a virCommandPassFD() call.
+ */
+static char *
+qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
+{
+char *result = NULL;
+int idx = virCommandPassFDGetFDIndex(cmd, fd);
+
+if (idx >= 0) {
+ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx) < 0);
+} else {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("file descriptor %d has not been transferred"), fd);
+}
+return result;
+}
+
+
+/**
  * qemuPhysIfaceConnect:
  * @def: the definition of the VM (needed by 802.1Qbh and audit)
  * @driver: pointer to the driver instance
@@ -6320,15 +6372,20 @@ qemuBuildRNGDevStr(virDomainDefPtr def,
 
 
 static char *qemuBuildTPMBackendStr(const virDomainDef *def,
+virCommandPtr cmd,
 virQEMUCapsPtr qemuCaps,
-const char *emulator)
+const char *emulator,
+int *tpmfd, int *cancelfd)
 {
 const virDomainTPMDef *tpm = def->tpm;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 const char *type = virDomainTPMBackendTypeToString(tpm->type);
-char *cancel_path;
+char *cancel_path = NULL, *devset = NULL;
 const char *tpmdev;
 
+*tpmfd = -1;
+*cancelfd = -1;
+
 virBufferAsprintf(&buf, "%s,id=tpm-%s", type, tpm->info.alias);
 
 switch (tpm->type) {
@@ -6340,11 +6397,42 @@ static char *qemuBuildTPMBackendStr(const virDomainDef 
*def,
 if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
 goto error;
 
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ADD_FD)) {
+*tpmfd = open(tpmdev, O_RDWR);
+if (*tpmfd < 0) {
+virReportSystemError(errno, _("Could not open TPM device %s"),
+ tpmdev);
+goto error;
+}
+
+virCommandPassFD(cmd, *tpmfd,
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+devset = qemuVirCommandGetDevSet(cmd, *tpmfd);
+if (devset == NULL)
+goto error;
+
+*cancelfd = open(cancel_path, O_WRONLY);
+if (*cancelfd < 0) {
+virReportSystemError(errno,
+ _("Could not open TPM device's cancel "
+   "path %s"), cancel_path);
+goto error;
+}
+VIR_FREE(cancel_path);
+
+virCommandPassFD(cmd, *cancelfd,
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+cancel_path = qemuVirCommandGetDevSet(cmd, *cancelfd);
+if (cancel_path == NULL)
+goto error;
+}
 virBufferAddLit(&buf, ",path=");
-virBufferEscape(&buf, ',', ",", "%s", tpmdev);
+virBufferEscape(&buf, ',', ",", "%s", devset ? devset : tpmdev);
 
 virBufferAddLit(&buf, ",cancel-path=");
 virBufferEscape(&buf, ',', ",", "%s", cancel_path);
+
+VIR_FREE(devset);
 VIR_FREE(cancel_path);
 
 break;
@@ -6364,6 +6452,9 @@ static char *qemuBuildTPMBackendStr(const virDomainDe

[libvirt] [PATCH 2/3] qemu: Move TPM command line build code into own function

2015-02-23 Thread Stefan Berger
Move the TPM command line build code into its own function.

Signed-off-by: Stefan Berger 
---
 src/qemu/qemu_command.c | 37 +
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7853125..539c956 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8148,6 +8148,30 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
 return ret;
 }
 
+static int
+qemuBuildTPMCommandLine(virDomainDefPtr def,
+virCommandPtr cmd,
+virQEMUCapsPtr qemuCaps,
+const char *emulator)
+{
+char *optstr;
+
+if (!(optstr = qemuBuildTPMBackendStr(def, qemuCaps, emulator)))
+return -1;
+
+virCommandAddArgList(cmd, "-tpmdev", optstr, NULL);
+VIR_FREE(optstr);
+
+if (!(optstr = qemuBuildTPMDevStr(def, qemuCaps, emulator)))
+return -1;
+
+virCommandAddArgList(cmd, "-device", optstr, NULL);
+VIR_FREE(optstr);
+
+return 0;
+}
+
+
 qemuBuildCommandLineCallbacks buildCommandLineCallbacks = {
 .qemuGetSCSIDeviceSgName = virSCSIDeviceGetSgName,
 };
@@ -9579,19 +9603,8 @@ qemuBuildCommandLine(virConnectPtr conn,
 }
 
 if (def->tpm) {
-char *optstr;
-
-if (!(optstr = qemuBuildTPMBackendStr(def, qemuCaps, emulator)))
+if (qemuBuildTPMCommandLine(def, cmd, qemuCaps, emulator) < 0)
 goto error;
-
-virCommandAddArgList(cmd, "-tpmdev", optstr, NULL);
-VIR_FREE(optstr);
-
-if (!(optstr = qemuBuildTPMDevStr(def, qemuCaps, emulator)))
-goto error;
-
-virCommandAddArgList(cmd, "-device", optstr, NULL);
-VIR_FREE(optstr);
 }
 
 for (i = 0; i < def->ninputs; i++) {
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/3] utils: Implement virCommandPassFDGetFDIndex

2015-02-23 Thread Stefan Berger
Implement virCommandPassFDGetFDIndex to determine the index a given
file descriptor will have when passed to the child process. When this
function is called, a flag is set to prevent the reordering of the
file descriptors.

Signed-off-by: Stefan Berger 
---
 src/libvirt_private.syms |  1 +
 src/util/vircommand.c| 33 +
 src/util/vircommand.h|  3 +++
 3 files changed, 37 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c156b40..aadb833 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1213,6 +1213,7 @@ virCommandNewArgList;
 virCommandNewArgs;
 virCommandNonblockingFDs;
 virCommandPassFD;
+virCommandPassFDGetFDIndex;
 virCommandPassListenFDs;
 virCommandRawStatus;
 virCommandRequireHandshake;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 6527d85..2616446 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -67,6 +67,7 @@ enum {
 VIR_EXEC_RUN_SYNC   = (1 << 3),
 VIR_EXEC_ASYNC_IO   = (1 << 4),
 VIR_EXEC_LISTEN_FDS = (1 << 5),
+VIR_EXEC_FIXED_FDS  = (1 << 6),
 };
 
 typedef struct _virCommandFD virCommandFD;
@@ -214,6 +215,12 @@ virCommandReorderFDs(virCommandPtr cmd)
 if (!cmd || cmd->has_error || !cmd->npassfd)
 return;
 
+if ((cmd->flags & VIR_EXEC_FIXED_FDS)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("The fds are fixed and cannot be reordered"));
+goto error;
+}
+
 for (i = 0; i < cmd->npassfd; i++)
 maxfd = MAX(cmd->passfd[i].fd, maxfd);
 
@@ -1019,6 +1026,32 @@ virCommandPassListenFDs(virCommandPtr cmd)
 cmd->flags |= VIR_EXEC_LISTEN_FDS;
 }
 
+/*
+ * virCommandPassFDGetFDIndex:
+ * @cmd: pointer to virCommand
+ * @fd: FD to get index of
+ *
+ * Determine the index of the FD in the transfer set.
+ *
+ * Returns index >= 0 if @set contains @fd,
+ * -1 otherwise.
+ */
+int
+virCommandPassFDGetFDIndex(virCommandPtr cmd, int fd)
+{
+size_t i = 0;
+
+while (i < cmd->npassfd) {
+if (cmd->passfd[i].fd == fd) {
+cmd->flags |= VIR_EXEC_FIXED_FDS;
+return i;
+}
+i++;
+}
+
+return -1;
+}
+
 /**
  * virCommandSetPidFile:
  * @cmd: the command to modify
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index bf65de4..198da2f 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -62,6 +62,9 @@ void virCommandPassFD(virCommandPtr cmd,
 
 void virCommandPassListenFDs(virCommandPtr cmd);
 
+int virCommandPassFDGetFDIndex(virCommandPtr cmd,
+   int fd);
+
 void virCommandSetPidFile(virCommandPtr cmd,
   const char *pidfile) ATTRIBUTE_NONNULL(2);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: Allow spaces in disk serial

2015-02-23 Thread Michal Privoznik
There's been a bug report appearing on the qemu-devel list, that
libvirt is unable to pass spaces in disk serial number [1]. Not only
our RNG schema forbids that, the code is not prepared either. However,
with a bit of escaping (if needed) we can allow spaces there.

1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html

Signed-off-by: Michal Privoznik 
---
 docs/schemas/domaincommon.rng  |  2 +-
 src/qemu/qemu_command.c|  5 ++--
 .../qemuxml2argvdata/qemuxml2argv-disk-serial.args |  6 +
 .../qemuxml2argvdata/qemuxml2argv-disk-serial.xml  | 27 ++
 tests/qemuxml2argvtest.c   |  5 
 5 files changed, 42 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f41ca43..09bd921 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5067,7 +5067,7 @@
   
   
 
-  [A-Za-z0-9_\.\+\-]+
+  [A-Za-z0-9_\.\+\- ]+
 
   
   
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7853125..b9adef6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2633,7 +2633,7 @@ qemuBuildIoEventFdStr(virBufferPtr buf,
 }
 
 #define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
-  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
+  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
 
 static int
 qemuSafeSerialParamValue(const char *value)
@@ -3616,7 +3616,8 @@ qemuBuildDriveStr(virConnectPtr conn,
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
 if (qemuSafeSerialParamValue(disk->serial) < 0)
 goto error;
-virBufferAsprintf(&opt, ",serial=%s", disk->serial);
+virBufferAddLit(&opt, ",serial=");
+virBufferEscapeShell(&opt, disk->serial);
 }
 
 if (disk->cachemode) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
new file mode 100644
index 000..8b08cfb
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/libexec/qemu-kvm -S -M pc -cpu qemu32 -m 214 -smp 1 -nographic 
-nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-drive 'file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1,serial='\''  
WD-WMAP9A966149'\''' \
+-device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
new file mode 100644
index 000..0fe75f3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
@@ -0,0 +1,27 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/libexec/qemu-kvm
+
+  
+  
+WD-WMAP9A966149
+  
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 16f325e..3032d1b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -904,6 +904,11 @@ mymain(void)
 QEMU_CAPS_DEVICE,
 QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_VIRTIO_BLK_SG_IO,
 QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-serial",
+QEMU_CAPS_KVM,
+QEMU_CAPS_DEVICE,
+QEMU_CAPS_DRIVE,
+QEMU_CAPS_DRIVE_SERIAL);
 
 DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
 DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
-- 
2.0.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Plan for next release

2015-02-23 Thread Daniel Veillard
  Oops, Feb is really short and I got caught, I think if we want a
release by beginning of March, i.e. next week we need to enter freeze
ASAP. So I'm suggesting to start the freeze tomorrow, for a release
on Monday if everything goes well !

  Hope this suits everybody,

   thanks,

Daniel


-- 
Daniel Veillard  | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: fix ifindex array reported to systemd

2015-02-23 Thread Daniel P. Berrange
On Fri, Feb 20, 2015 at 04:05:22PM -0500, Laine Stump wrote:
> Commit f7afeddc added code to report to systemd an array of interface
> indexes for all tap devices used by a guest. Unfortunately it not only
> didn't add code to report the ifindexes for macvtap interfaces
> (interface type='direct') or the tap devices used by type='ethernet',
> it ended up sending "-1" as the ifindex for each macvtap or hostdev
> interface. This resulted in a failure to start any domain that had a
> macvtap or hostdev interface (or actually any type other than
> "network" or "bridge").
> 
> This patch modifies qemuBuildInterfaceCommandLine() to only add an
> entry to the array of ifindexes for appropriate types, and to do so
> for all appropriate types ("network", "bridge", and "direct").
> ---
>  src/qemu/qemu_command.c | 59 
> ++---
>  src/qemu/qemu_command.h |  5 ++---
>  src/qemu/qemu_hotplug.c |  6 ++---
>  3 files changed, 50 insertions(+), 20 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 7853125..81f6982 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -289,8 +289,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
>  virDomainNetDefPtr net,
>  virQEMUCapsPtr qemuCaps,
>  int *tapfd,
> -size_t *tapfdSize,
> -int *nicindex)
> +size_t *tapfdSize)
>  {
>  const char *brname;
>  int ret = -1;
> @@ -337,8 +336,6 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
>  virDomainAuditNetDevice(def, net, tunpath, false);
>  goto cleanup;
>  }
> -if (virNetDevGetIndex(net->ifname, nicindex) < 0)
> -goto cleanup;
>  if (virDomainNetGetActualBridgeMACTableManager(net)
>  == VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
>  /* libvirt is managing the FDB of the bridge this device
> @@ -7756,7 +7753,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>int bootindex,
>virNetDevVPortProfileOp vmop,
>bool standalone,
> -  int *nicindex)
> +  size_t *nnicindexes,
> +  int **nicindexes)
>  {
>  int ret = -1;
>  char *nic = NULL, *host = NULL;
> @@ -7770,8 +7768,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>  virNetDevBandwidthPtr actualBandwidth;
>  size_t i;
>  
> -*nicindex = -1;
> -
>  if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
>  return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps);
>  
> @@ -7818,7 +7814,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>  
>  if (qemuNetworkIfaceConnect(def, driver, net,
>  qemuCaps, tapfd,
> -&tapfdSize, nicindex) < 0)
> +&tapfdSize) < 0)
>  goto cleanup;
>  } else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
>  if (VIR_ALLOC(tapfd) < 0 || VIR_ALLOC(tapfdName) < 0)
> @@ -7830,6 +7826,47 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>  goto cleanup;
>  }
>  
> +/* For types whose implementions use a netdev on the host, add an
> + * entry to nicifindexes for passing on to systemd.
> +*/
> +switch ((virDomainNetType)actualType) {
> +case VIR_DOMAIN_NET_TYPE_ETHERNET:
> +case VIR_DOMAIN_NET_TYPE_NETWORK:
> +case VIR_DOMAIN_NET_TYPE_BRIDGE:
> +case VIR_DOMAIN_NET_TYPE_DIRECT:
> +{
> +int nicindex;
> +
> +/* network and bridge use a tap device, and direct uses a
> + * macvtap device
> + */
> +   if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
> +   VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
> +  goto cleanup;
> +   break;
> +}
> +
> +case VIR_DOMAIN_NET_TYPE_USER:
> +case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
> +case VIR_DOMAIN_NET_TYPE_SERVER:
> +case VIR_DOMAIN_NET_TYPE_CLIENT:
> +case VIR_DOMAIN_NET_TYPE_MCAST:
> +case VIR_DOMAIN_NET_TYPE_INTERNAL:
> +case VIR_DOMAIN_NET_TYPE_HOSTDEV:
> +case VIR_DOMAIN_NET_TYPE_LAST:
> +   /* These types don't use a network device on the host, but
> +* instead use some other type of connection to the emulated
> +* device in the qemu process.
> +*
> +* (Note that hostdev can't be considered as "using a network
> +* device", because by the time it is being used, it has been
> +* detached from the hostside network driver so it doesn't show
> +* up in the list of interfaces on the host - it's just some
> +* PCI device.)
> +*/
> +   break;
> +}
> +
>  /* Set bandwidth or warn if requested and not supported