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

ffd6ed
From 2392578b6774594eb33188606fd64c415055be63 Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Thu, 2 Oct 2014 16:44:07 +0100
0d20ef
Subject: [PATCH] RHEL 7: Revert "launch: libvirt: Use qemu-bridge-helper to
0d20ef
 implement a full network (RHBZ#1148012)."
0d20ef
0d20ef
This reverts commit 224de20b9a8d5ea56f6337f19b4ca237bb88eca0.
0d20ef
---
0d20ef
 src/guestfs.pod      | 10 ----------
0d20ef
 src/launch-libvirt.c | 44 +++++++++++++++++++++-----------------------
0d20ef
 2 files changed, 21 insertions(+), 33 deletions(-)
0d20ef
0d20ef
diff --git a/src/guestfs.pod b/src/guestfs.pod
ffd6ed
index 3c1ad46..81347f3 100644
0d20ef
--- a/src/guestfs.pod
0d20ef
+++ b/src/guestfs.pod
ffd6ed
@@ -1419,16 +1419,6 @@ On Fedora, install C<kernel-debuginfo> for the C<vmlinux> file
0d20ef
 (containing symbols).  Make sure the symbols precisely match the
0d20ef
 kernel being used.
0d20ef
 
0d20ef
-=head3 network_bridge
0d20ef
-
0d20ef
-The libvirt backend supports:
0d20ef
-
0d20ef
- export LIBGUESTFS_BACKEND_SETTINGS=network_bridge=virbrX
0d20ef
-
0d20ef
-This allows you to override the bridge that is connected to when the
0d20ef
-network is enabled.  The default is C<virbr0>.  See also
0d20ef
-L</guestfs_set_network>.
0d20ef
-
0d20ef
 =head2 ATTACHING TO RUNNING DAEMONS
0d20ef
 
0d20ef
 I<Note (1):> This is B<highly experimental> and has a tendency to eat
0d20ef
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
ffd6ed
index 79bc6fd..026fd5a 100644
0d20ef
--- a/src/launch-libvirt.c
0d20ef
+++ b/src/launch-libvirt.c
0d20ef
@@ -105,7 +105,6 @@ struct backend_libvirt_data {
0d20ef
   char *selinux_label;
0d20ef
   char *selinux_imagelabel;
0d20ef
   bool selinux_norelabel_disks;
0d20ef
-  char *network_bridge;
0d20ef
   char name[DOMAIN_NAME_LEN];   /* random name */
0d20ef
   bool is_kvm;                  /* false = qemu, true = kvm (from capabilities)*/
0d20ef
   unsigned long qemu_version;   /* qemu version (from libvirt) */
ffd6ed
@@ -332,12 +331,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
0d20ef
     guestfs_get_backend_setting (g, "internal_libvirt_imagelabel");
0d20ef
   data->selinux_norelabel_disks =
0d20ef
     guestfs___get_backend_setting_bool (g, "internal_libvirt_norelabel_disks");
0d20ef
-  if (g->enable_network) {
0d20ef
-    data->network_bridge =
0d20ef
-      guestfs_get_backend_setting (g, "network_bridge");
0d20ef
-    if (!data->network_bridge)
0d20ef
-      data->network_bridge = safe_strdup (g, "virbr0");
0d20ef
-  }
0d20ef
   guestfs_pop_error_handler (g);
0d20ef
 
0d20ef
   /* Locate and/or build the appliance. */
ffd6ed
@@ -1267,19 +1260,6 @@ construct_libvirt_xml_devices (guestfs_h *g,
0d20ef
       } end_element ();
0d20ef
     } end_element ();
0d20ef
 
0d20ef
-    /* Connect to libvirt bridge (see: RHBZ#1148012). */
0d20ef
-    if (g->enable_network) {
0d20ef
-      start_element ("interface") {
0d20ef
-        attribute ("type", "bridge");
0d20ef
-        start_element ("source") {
0d20ef
-          attribute ("bridge", params->data->network_bridge);
0d20ef
-        } end_element ();
0d20ef
-        start_element ("model") {
0d20ef
-          attribute ("type", "virtio");
0d20ef
-        } end_element ();
0d20ef
-      } end_element ();
0d20ef
-    }
0d20ef
-
0d20ef
   } end_element (); /* </devices> */
0d20ef
 
0d20ef
   return 0;
ffd6ed
@@ -1661,6 +1641,27 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g,
0d20ef
       attribute ("value", tmpdir);
0d20ef
     } end_element ();
0d20ef
 
0d20ef
+    /* Workaround because libvirt user networking cannot specify "net="
0d20ef
+     * parameter.
0d20ef
+     */
0d20ef
+    if (g->enable_network) {
0d20ef
+      start_element ("qemu:arg") {
0d20ef
+        attribute ("value", "-netdev");
0d20ef
+      } end_element ();
0d20ef
+
0d20ef
+      start_element ("qemu:arg") {
0d20ef
+        attribute ("value", "user,id=usernet,net=169.254.0.0/16");
0d20ef
+      } end_element ();
0d20ef
+
0d20ef
+      start_element ("qemu:arg") {
0d20ef
+        attribute ("value", "-device");
0d20ef
+      } end_element ();
0d20ef
+
0d20ef
+      start_element ("qemu:arg") {
0d20ef
+        attribute ("value", VIRTIO_NET ",netdev=usernet");
0d20ef
+      } end_element ();
0d20ef
+    }
0d20ef
+
0d20ef
     /* The qemu command line arguments requested by the caller. */
0d20ef
     for (hp = g->hv_params; hp; hp = hp->next) {
0d20ef
       start_element ("qemu:arg") {
ffd6ed
@@ -1745,9 +1746,6 @@ shutdown_libvirt (guestfs_h *g, void *datav, int check_for_errors)
0d20ef
   free (data->selinux_imagelabel);
0d20ef
   data->selinux_imagelabel = NULL;
0d20ef
 
0d20ef
-  free (data->network_bridge);
0d20ef
-  data->network_bridge = NULL;
0d20ef
-
ffd6ed
   free (data->uefi_code);
ffd6ed
   data->uefi_code = NULL;
ffd6ed
   free (data->uefi_vars);
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef