|
|
d03fcc |
From 80899629519139a7eb86842942a9471d05eb4112 Mon Sep 17 00:00:00 2001
|
|
|
d03fcc |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
d03fcc |
Date: Thu, 23 Dec 2021 11:37:00 +0100
|
|
|
d03fcc |
Subject: [PATCH] lib: extract NETWORK_ADDRESS and NETWORK_PREFIX as macros
|
|
|
d03fcc |
|
|
|
d03fcc |
The 169.254.0.0/16 network specification (for the appliance) is currently
|
|
|
d03fcc |
duplicated between the direct backend and the libvirt backend. In a
|
|
|
d03fcc |
subsequent patch, we're going to need the network specification in yet
|
|
|
d03fcc |
another spot; extract it now to the NETWORK_ADDRESS and NETWORK_PREFIX
|
|
|
d03fcc |
macros (simply as strings).
|
|
|
d03fcc |
|
|
|
d03fcc |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034160
|
|
|
d03fcc |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
d03fcc |
Message-Id: <20211223103701.12702-3-lersek@redhat.com>
|
|
|
d03fcc |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
d03fcc |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
d03fcc |
(cherry picked from commit 216de164e091a5c36403f24901698044a43ae0d9)
|
|
|
d03fcc |
---
|
|
|
d03fcc |
lib/guestfs-internal.h | 6 ++++++
|
|
|
d03fcc |
lib/launch-direct.c | 2 +-
|
|
|
d03fcc |
lib/launch-libvirt.c | 3 ++-
|
|
|
d03fcc |
3 files changed, 9 insertions(+), 2 deletions(-)
|
|
|
d03fcc |
|
|
|
d03fcc |
diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h
|
|
|
d03fcc |
index 8eb2dd3ad..e24d570f5 100644
|
|
|
d03fcc |
--- a/lib/guestfs-internal.h
|
|
|
d03fcc |
+++ b/lib/guestfs-internal.h
|
|
|
d03fcc |
@@ -183,6 +183,12 @@ cleanup_mutex_unlock (pthread_mutex_t **ptr)
|
|
|
d03fcc |
#endif
|
|
|
d03fcc |
#endif
|
|
|
d03fcc |
|
|
|
d03fcc |
+/* Network address and network mask (expressed as address prefix) that the
|
|
|
d03fcc |
+ * appliance will see (if networking is enabled).
|
|
|
d03fcc |
+ */
|
|
|
d03fcc |
+#define NETWORK_ADDRESS "169.254.0.0"
|
|
|
d03fcc |
+#define NETWORK_PREFIX "16"
|
|
|
d03fcc |
+
|
|
|
d03fcc |
/* Guestfs handle and associated structures. */
|
|
|
d03fcc |
|
|
|
d03fcc |
/* State. */
|
|
|
d03fcc |
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
|
|
|
d03fcc |
index e5b9a5611..4f038f4f0 100644
|
|
|
d03fcc |
--- a/lib/launch-direct.c
|
|
|
d03fcc |
+++ b/lib/launch-direct.c
|
|
|
d03fcc |
@@ -689,7 +689,7 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
|
|
|
d03fcc |
start_list ("-netdev") {
|
|
|
d03fcc |
append_list ("user");
|
|
|
d03fcc |
append_list ("id=usernet");
|
|
|
d03fcc |
- append_list ("net=169.254.0.0/16");
|
|
|
d03fcc |
+ append_list ("net=" NETWORK_ADDRESS "/" NETWORK_PREFIX);
|
|
|
d03fcc |
} end_list ();
|
|
|
d03fcc |
start_list ("-device") {
|
|
|
d03fcc |
append_list (VIRTIO_DEVICE_NAME ("virtio-net"));
|
|
|
d03fcc |
diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
|
|
|
d03fcc |
index 9e8336938..266d88824 100644
|
|
|
d03fcc |
--- a/lib/launch-libvirt.c
|
|
|
d03fcc |
+++ b/lib/launch-libvirt.c
|
|
|
d03fcc |
@@ -1843,7 +1843,8 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g,
|
|
|
d03fcc |
} end_element ();
|
|
|
d03fcc |
|
|
|
d03fcc |
start_element ("qemu:arg") {
|
|
|
d03fcc |
- attribute ("value", "user,id=usernet,net=169.254.0.0/16");
|
|
|
d03fcc |
+ attribute ("value",
|
|
|
d03fcc |
+ "user,id=usernet,net=" NETWORK_ADDRESS "/" NETWORK_PREFIX);
|
|
|
d03fcc |
} end_element ();
|
|
|
d03fcc |
|
|
|
d03fcc |
start_element ("qemu:arg") {
|
|
|
d03fcc |
--
|
|
|
69da20 |
2.31.1
|
|
|
d03fcc |
|