Re: [PATCH] libxl: Fix domxml-to-native conversion

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

 



On 5/2/24 5:24 AM, Ján Tomko wrote:
On a Monday in 2024, Jim Fehlig via Devel wrote:
Similar to commit 57d084febe, another case of the libxl driver not
adapting to modular daemons. When converting configuration that
contains a type='network' interface, the converter calls
virNetworkLookupByName, passing the hypervisor connection object
instead of a connection to virtnetworkd. E.g.

cat dom.xml
...
   <interface type='network'>
     <source network='default'/>
   </interface>
...
virsh net-info default
Name:           default
UUID:           25a5b089-1e71-4956-99aa-df2213bbb407
Active:         yes
Persistent:     no
Autostart:      no
Bridge:         virbr0
virsh domxml-to-native xen-xl dom.xml
error: Network not found: default

Acquire a connection to virtnetworkd and use it when calling
virNetwork* APIs.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
src/libxl/libxl_driver.c |  4 ++--
src/libxl/xen_common.c   | 25 +++++++++++++++----------
src/libxl/xen_common.h   |  1 -
src/libxl/xen_xl.c       |  4 ++--
src/libxl/xen_xl.h       |  2 +-
src/libxl/xen_xm.c       |  5 ++---
src/libxl/xen_xm.h       |  2 +-
tests/xlconfigtest.c     |  7 +------
tests/xmconfigtest.c     |  7 +------
9 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 79eb593432..0b2346d8b5 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -24,6 +24,7 @@

#include <config.h>

+#include "driver.h"
#include "internal.h"
#include "virerror.h"
#include "virconf.h"
@@ -1586,8 +1587,7 @@ xenMakeIPList(virNetDevIPInfo *guestIP)
}

static int
-xenFormatNet(virConnectPtr conn,
-             virConfValue *list,
+xenFormatNet(virConfValue *list,
             virDomainNetDef *net,
             int hvm,
             const char *vif_typename)
@@ -1649,13 +1649,21 @@ xenFormatNet(virConnectPtr conn,

    case VIR_DOMAIN_NET_TYPE_NETWORK:
    {
-        virNetworkPtr network = virNetworkLookupByName(conn, net->data.network.name);
+        virConnectPtr conn = NULL;

You can use:

g_autoptr(virConnect) conn = NULL;

to avoid adding the unref on both branches.

Ah right, thanks for the reminder. I squashed in the below diff before pushing.

Regards,
Jim

diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 0b2346d8b5..3a64f565f7 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -24,6 +24,7 @@

 #include <config.h>

+#include "datatypes.h"
 #include "driver.h"
 #include "internal.h"
 #include "virerror.h"
@@ -1649,7 +1650,7 @@ xenFormatNet(virConfValue *list,

     case VIR_DOMAIN_NET_TYPE_NETWORK:
     {
-        virConnectPtr conn = NULL;
+        g_autoptr(virConnect) conn = NULL;
         virNetworkPtr network;
         char *bridge;

@@ -1659,10 +1660,8 @@ xenFormatNet(virConfValue *list,
         if (!(network = virNetworkLookupByName(conn, net->data.network.name))) {
             virReportError(VIR_ERR_NO_NETWORK, "%s",
                            net->data.network.name);
-            virObjectUnref(conn);
             return -1;
         }
-        virObjectUnref(conn);

         bridge = virNetworkGetBridgeName(network);
         virObjectUnref(network);
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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]

  Powered by Linux