Re: [PATCH 2/9] qemuDomain{Attach, Remove}NetDevice: Prefer qemuDomainSupportsNetdev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 08/16/2016 11:41 AM, Michal Privoznik wrote:
> Depending on domain OS type, and interface address type we might
> not want to use -netdev even though qemu has the capability. We
> should use more advanced check implemented in
> qemuDomainSupportsNetdev() function.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_hotplug.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 

Seems to me part of the goal here is to follow the decision points that
qemu_command.c would make in qemuBuildInterfaceCommandLine, but that
logic isn't all that clear either.

If it helps, I'm in favor of the change - although I have a couple of
concerns (and per usual I left some thoughts along the way)...

it's a weak ACK, but let's see what you/Laine think too

John

> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index d1acdd9..feb1f44 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1108,7 +1108,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>  
>      releaseaddr = true;
>  
> -    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +    if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {

same check as qemuBuildNetCommandLine, so this looks right.

>          vlan = -1;
>      } else {
>          vlan = qemuDomainNetVLAN(net);
> @@ -1134,7 +1134,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>              goto cleanup;
>      }
>  
> -    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +    if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {
>          if (!(netstr = qemuBuildHostNetStr(net, driver,
>                                             ',', -1,

FWIW: That -1 is also 'vlan' value *if* qemuDomainSupportsNetdev is used
and true. If you follow the qemu_command logic, it too would pass -1 in
the vlan to qemuBuildInterfaceCommandLine.  So "theoretically" we're
still on par with qemu_command processing...

The else portion of the hotplug code doesn't seem to match the
qemu_command code's !qemuDomainSupportsNetdev and qemuBuildHostNetStr
call though (' ' vs. ',').  I know - separate issue, but I figured I'd
point it out at least.

>                                             tapfdName, tapfdSize,
> @@ -1149,7 +1149,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>      }
>  
>      qemuDomainObjEnterMonitor(driver, vm);
> -    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +    if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {

This particular check/usage isn't as clear to me at least with respect
to comparing to qemu_command processing of "-device" and hotplug usage
of netdev_add.  As for the else condition, it's qemu_command usage of
"-net" and (text only) hotplug usage of host_net_add.

As long as those are "equals", then this check seems to pass muster
too... At least w/r/t how qemu_command does things.

>          if (qemuMonitorAddNetdev(priv->mon, netstr,
>                                   tapfd, tapfdName, tapfdSize,
>                                   vhostfd, vhostfdName, vhostfdSize) < 0) {
> @@ -1195,7 +1195,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>          } else {
>              qemuDomainObjEnterMonitor(driver, vm);
>  
> -            if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +            if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {

This would seemingly be OK

>                  if (qemuMonitorSetLink(priv->mon, net->info.alias, VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) < 0) {
>                      ignore_value(qemuDomainObjExitMonitor(driver, vm));
>                      virDomainAuditNet(vm, NULL, net, "attach", false);
> @@ -1278,7 +1278,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>          goto cleanup;
>  
>      if (vlan < 0) {
> -        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +        if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {

This would match, error code...

>              char *netdev_name;
>              if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0)
>                  goto cleanup;
> @@ -3326,7 +3326,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
>          goto cleanup;
>  
>      qemuDomainObjEnterMonitor(driver, vm);
> -    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
> +    if (qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) {

and this would be the corollary to our Attach which seems OK.

>          if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
>              if (qemuDomainObjExitMonitor(driver, vm) < 0)
>                  goto cleanup;
> 

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]