mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0009-RHEL-7-Revert-launch-libvirt-Use-qemu-bridge-helper-.patch

151578
From 5a411a67cf166eb44b8f88858eabaa80d6a0d504 Mon Sep 17 00:00:00 2001
151578
From: "Richard W.M. Jones" <rjones@redhat.com>
151578
Date: Thu, 2 Oct 2014 16:44:07 +0100
151578
Subject: [PATCH] RHEL 7: Revert "launch: libvirt: Use qemu-bridge-helper to
151578
 implement a full network (RHBZ#1148012)."
151578
151578
This reverts commit 224de20b9a8d5ea56f6337f19b4ca237bb88eca0.
151578
---
151578
 lib/guestfs.pod      | 10 ----------
151578
 lib/launch-libvirt.c | 44 +++++++++++++++++++++-----------------------
151578
 2 files changed, 21 insertions(+), 33 deletions(-)
151578
151578
diff --git a/lib/guestfs.pod b/lib/guestfs.pod
151578
index 41aa7ad83..6443e3bae 100644
151578
--- a/lib/guestfs.pod
151578
+++ b/lib/guestfs.pod
151578
@@ -1441,16 +1441,6 @@ On Fedora, install C<kernel-debuginfo> for the C<vmlinux> file
151578
 (containing symbols).  Make sure the symbols precisely match the
151578
 kernel being used.
151578
 
151578
-=head3 network_bridge
151578
-
151578
-The libvirt backend supports:
151578
-
151578
- export LIBGUESTFS_BACKEND_SETTINGS=network_bridge=virbrX
151578
-
151578
-This allows you to override the bridge that is connected to when the
151578
-network is enabled.  The default is C<virbr0>.  See also
151578
-L</guestfs_set_network>.
151578
-
151578
 =head2 ATTACHING TO RUNNING DAEMONS
151578
 
151578
 I<Note (1):> This is B<highly experimental> and has a tendency to eat
151578
diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
151578
index 4ddf9b87f..def9cfe07 100644
151578
--- a/lib/launch-libvirt.c
151578
+++ b/lib/launch-libvirt.c
151578
@@ -115,7 +115,6 @@ struct backend_libvirt_data {
151578
   char *selinux_label;
151578
   char *selinux_imagelabel;
151578
   bool selinux_norelabel_disks;
151578
-  char *network_bridge;
151578
   char name[DOMAIN_NAME_LEN];   /* random name */
151578
   bool is_kvm;                  /* false = qemu, true = kvm (from capabilities)*/
151578
   struct version libvirt_version; /* libvirt version */
151578
@@ -435,12 +434,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
151578
     guestfs_get_backend_setting (g, "internal_libvirt_imagelabel");
151578
   data->selinux_norelabel_disks =
151578
     guestfs_int_get_backend_setting_bool (g, "internal_libvirt_norelabel_disks");
151578
-  if (g->enable_network) {
151578
-    data->network_bridge =
151578
-      guestfs_get_backend_setting (g, "network_bridge");
151578
-    if (!data->network_bridge)
151578
-      data->network_bridge = safe_strdup (g, "virbr0");
151578
-  }
151578
   guestfs_pop_error_handler (g);
151578
 
151578
   if (g->enable_network && check_bridge_exists (g, data->network_bridge) == -1)
151578
@@ -1383,19 +1376,6 @@ construct_libvirt_xml_devices (guestfs_h *g,
151578
       } end_element ();
151578
     } end_element ();
151578
 
151578
-    /* Connect to libvirt bridge (see: RHBZ#1148012). */
151578
-    if (g->enable_network) {
151578
-      start_element ("interface") {
151578
-        attribute ("type", "bridge");
151578
-        start_element ("source") {
151578
-          attribute ("bridge", params->data->network_bridge);
151578
-        } end_element ();
151578
-        start_element ("model") {
151578
-          attribute ("type", "virtio");
151578
-        } end_element ();
151578
-      } end_element ();
151578
-    }
151578
-
151578
     /* Libvirt adds some devices by default.  Indicate to libvirt
151578
      * that we don't want them.
151578
      */
151578
@@ -1793,6 +1773,27 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g,
151578
       attribute ("value", tmpdir);
151578
     } end_element ();
151578
 
151578
+    /* Workaround because libvirt user networking cannot specify "net="
151578
+     * parameter.
151578
+     */
151578
+    if (g->enable_network) {
151578
+      start_element ("qemu:arg") {
151578
+        attribute ("value", "-netdev");
151578
+      } end_element ();
151578
+
151578
+      start_element ("qemu:arg") {
151578
+        attribute ("value", "user,id=usernet,net=169.254.0.0/16");
151578
+      } end_element ();
151578
+
151578
+      start_element ("qemu:arg") {
151578
+        attribute ("value", "-device");
151578
+      } end_element ();
151578
+
151578
+      start_element ("qemu:arg") {
151578
+        attribute ("value", VIRTIO_NET ",netdev=usernet");
151578
+      } end_element ();
151578
+    }
151578
+
151578
     /* The qemu command line arguments requested by the caller. */
151578
     for (hp = g->hv_params; hp; hp = hp->next) {
151578
       start_element ("qemu:arg") {
151578
@@ -2118,9 +2119,6 @@ shutdown_libvirt (guestfs_h *g, void *datav, int check_for_errors)
151578
   free (data->selinux_imagelabel);
151578
   data->selinux_imagelabel = NULL;
151578
 
151578
-  free (data->network_bridge);
151578
-  data->network_bridge = NULL;
151578
-
151578
   for (i = 0; i < data->nr_secrets; ++i)
151578
     free (data->secrets[i].secret);
151578
   free (data->secrets);
151578
-- 
151578
2.14.3
151578