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

e9bfca
From af775f107327930e5d81bd63b5c682bb6925ba21 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
e9bfca
index 684f8dc6c..0b8c9f7d2 100644
151578
--- a/lib/guestfs.pod
151578
+++ b/lib/guestfs.pod
e9bfca
@@ -1451,16 +1451,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
e9bfca
index 844023b80..f0f52fba0 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 */
e9bfca
@@ -437,12 +436,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)
e9bfca
@@ -1402,19 +1395,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
      */
e9bfca
@@ -1810,6 +1790,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") {
e9bfca
+        attribute ("value", VIRTIO_DEVICE_NAME ("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") {
e9bfca
@@ -2135,9 +2136,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
-- 
8ff76f
2.20.1
151578