Skip to content

Commit

Permalink
Upgraded to stable xen-tools 4.19.0 and fixed yetus space/tab complaints
Browse files Browse the repository at this point in the history
Signed-off-by: Roja Eswaran <[email protected]>
  • Loading branch information
roja-zededa committed Aug 8, 2024
1 parent 512ab89 commit 227db95
Show file tree
Hide file tree
Showing 16 changed files with 1,098 additions and 6 deletions.
9 changes: 4 additions & 5 deletions pkg/xen-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ ENV BUILD_PKGS \
pixman-dev libaio-dev yajl-dev argp-standalone \
linux-headers git patch texinfo tar libcap-ng-dev \
attr-dev flex bison cmake libusb-dev zstd-dev \
python3 build-base

python3 build-base
ENV BUILD_PKGS_arm64 dtc-dev

ENV PKGS alpine-baselayout libgcc musl-utils bash libaio libbz2 glib pixman yajl keyutils libusb xz-libs libuuid sudo zstd-libs
Expand Down Expand Up @@ -62,7 +61,7 @@ RUN strip /out/usr/lib/* || :


# When changing this version, also update SEABIOS_UPSTREAM_REVISION to whatever is in `Config.mk` in the xen source
ENV XEN_VERSION 4.19.0-rc4
ENV XEN_VERSION 4.19.0
ENV XEN_SOURCE=https://downloads.xenproject.org/release/xen/${XEN_VERSION}/xen-${XEN_VERSION}.tar.gz
ENV EXTRA_QEMUU_CONFIGURE_ARGS="--enable-libusb --enable-linux-aio \
--enable-vhost-net --enable-vhost-kernel \
Expand Down Expand Up @@ -119,8 +118,8 @@ WORKDIR /xen
# disable golang as it does not play well together with musl (stderr is defined as FILE* const and fails to compile)
RUN apk add ninja
RUN ./configure --prefix=/usr --disable-xen --disable-golang --disable-qemu-traditional --disable-docs --enable-9pfs \
--with-system-ovmf=/usr/lib/xen/boot/ovmf.bin --disable-stubdom \
--enable-vhost-vsock --enable-vhost-scsi
--with-system-ovmf=/usr/lib/xen/boot/ovmf.bin --disable-stubdom \

Check failure on line 121 in pkg/xen-tools/Dockerfile

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
--enable-vhost-vsock --enable-vhost-scsi

Check failure on line 122 in pkg/xen-tools/Dockerfile

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
RUN make -j "$(getconf _NPROCESSORS_ONLN)" && make dist
RUN dist/install.sh /out

Expand Down
33 changes: 33 additions & 0 deletions pkg/xen-tools/patches-4.19.0/00-musl-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c
index d0571cabac..7ad86e3b31 100644
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -180,7 +180,7 @@ static int xenpaging_get_tot_pages(struct xenpaging *paging)

static void *init_page(void)
{
- void *buffer;
+ void *buffer = NULL;

/* Allocated page memory */
errno = posix_memalign(&buffer, PAGE_SIZE, PAGE_SIZE);
--- a/tools/Makefile 2019-09-11 13:15:12.000000000 -0700
+++ b/tools/Makefile 2019-09-11 13:14:58.000000000 -0700
@@ -245,7 +245,8 @@
--prefix=$(LIBEXEC) \
--libdir=$(LIBEXEC_LIB) \
--includedir=$(LIBEXEC_INC) \
- --extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \
+ --extra-cflags="-DXATTR_SIZE_MAX=65536 \
+ -DXC_WANT_COMPAT_EVTCHN_API=1 \
-DXC_WANT_COMPAT_GNTTAB_API=1 \
-DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \
-DXC_WANT_COMPAT_DEVICEMODEL_API=1 \
@@ -280,6 +281,7 @@
--localstatedir=$(localstatedir) \
--disable-kvm \
--disable-docs \
+ --disable-werror \
--disable-guest-agent \
--python=$(PYTHON) \
$(CONFIG_QEMUU_EXTRA_ARGS) \
13 changes: 13 additions & 0 deletions pkg/xen-tools/patches-4.19.0/01-enable-gmp-patching.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/stubdom/Makefile b/stubdom/Makefile
index 8cf7131c6a..c6a8051c85 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -178,7 +178,7 @@ gmp-$(XEN_TARGET_ARCH): gmp-$(GMP_VERSION).tar.bz2 $(NEWLIB_STAMPFILE)
tar xjf $<
rm $@ -rf || :
mv gmp-$(GMP_VERSION) $@
- #patch -d $@ -p0 < gmp.patch
+ patch -d $@ -p0 < gmp.patch
cd $@; CPPFLAGS="-isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include $(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" CC=$(CC) $(GMPEXT) ./configure --disable-shared --enable-static --disable-fft --without-readline --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --libdir=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib --build=`gcc -dumpmachine` --host=$(GNU_TARGET_ARCH)-xen-elf
sed -i 's/#define HAVE_OBSTACK_VPRINTF 1/\/\/#define HAVE_OBSTACK_VPRINTF 1/' $@/config.h
touch $@
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/tools/hotplug/Linux/vif-bridge
+++ b/tools/hotplug/Linux/vif-bridge
@@ -93,7 +93,6 @@ case "$command" in
;;
esac

-handle_iptable

call_hooks vif post

193 changes: 193 additions & 0 deletions pkg/xen-tools/patches-4.19.0/08-memlogd-logger.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index a43c57edad..d0bf636c10 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -27,6 +27,8 @@
#include <xen/io/console.h>
#include <xen/grant_table.h>

+#include "../libs/light/xentoollog_external.h"
+
#include <stdlib.h>
#include <errno.h>
#include <string.h>
@@ -420,6 +422,15 @@ static int create_hv_log(void)
{
char logfile[PATH_MAX];
int fd;
+
+ fd = xtl_logger_create_external("hypervisor");
+ if (fd < 0) {
+ dolog(LOG_ERR, "Failed to establish connection with the external logger - falling back %d (%s)",
+ errno, strerror(errno));
+ } else {
+ return fd;
+ }
+
snprintf(logfile, PATH_MAX-1, "%s/hypervisor.log", log_dir);
logfile[PATH_MAX-1] = '\0';

@@ -444,6 +455,7 @@ static int create_hv_log(void)
static int create_console_log(struct console *con)
{
char logfile[PATH_MAX];
+ char logname[PATH_MAX];
char *namepath, *data, *s;
int fd;
unsigned int len;
@@ -468,9 +480,20 @@ static int create_console_log(struct console *con)

snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log",
log_dir, data, con->log_suffix);
+ snprintf(logname, PATH_MAX-1, "guest_vm-%s%s",
+ data, con->log_suffix);

free(data);
logfile[PATH_MAX-1] = '\0';
+ logname[PATH_MAX-1] = '\0';
+
+ fd = xtl_logger_create_external(logname);
+ if (fd < 0) {
+ dolog(LOG_ERR, "Failed to establish connection with the external logger - falling back %d (%s)",
+ errno, strerror(errno));
+ } else {
+ return fd;
+ }

fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
if (fd == -1)
diff --git a/tools/libs/light/xentoollog_external.h b/tools/libs/light/xentoollog_external.h
new file mode 100644
index 0000000000..4b664fc36e
--- /dev/null
+++ b/tools/libs/light/xentoollog_external.h
@@ -0,0 +1,68 @@
+#ifndef XENTOOLLOG_EXTERNAL_H
+#define XENTOOLLOG_EXTERNAL_H
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define XTL_EXTERNAL_LOGGER_SOCKET "/var/run/linuxkit-external-logging.sock"
+extern int xtl_logger_create_external(char *name);
+int xtl_logger_create_external(char *name) {
+ int fds[2];
+ int fd;
+ struct sockaddr_un addr;
+ struct msghdr message;
+ struct iovec iov[1];
+ struct cmsghdr *control_message = NULL;
+ char ctrl_buf[CMSG_SPACE(sizeof(int))];
+
+ /* fill out all the required C paperwork */
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, XTL_EXTERNAL_LOGGER_SOCKET);
+
+ memset(&message, 0, sizeof(struct msghdr));
+ memset(ctrl_buf, 0, CMSG_SPACE(sizeof(int)));
+ iov[0].iov_base = name;
+ iov[0].iov_len = strlen(name);
+
+ message.msg_name = NULL;
+ message.msg_namelen = 0;
+ message.msg_iov = iov;
+ message.msg_iovlen = 1;
+ message.msg_controllen = CMSG_SPACE(sizeof(int));
+ message.msg_control = ctrl_buf;
+
+ control_message = CMSG_FIRSTHDR(&message);
+ control_message->cmsg_level = SOL_SOCKET;
+ control_message->cmsg_type = SCM_RIGHTS;
+ control_message->cmsg_len = CMSG_LEN(sizeof(int));
+
+ /* now, do the deed */
+ fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (fd < 0)
+ goto bail;
+
+ if (pipe(fds))
+ goto bail_fd;
+
+ *((int *) CMSG_DATA(control_message)) = fds[0];
+
+ if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+ goto bail_fd_fds;
+
+ if (sendmsg(fd, &message, 0) >= 0) {
+ return fds[1];
+ }
+
+bail_fd_fds:
+ close(fds[0]);
+ close(fds[1]);
+bail_fd:
+ close(fd);
+bail:
+ return -1;
+}
+
+#endif /* XENTOOLLOG_EXTERNAL_H */
diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index dac1b8ddb8..a368fe6ba0 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -25,6 +25,8 @@
#include <pwd.h>
#include <grp.h>

+#include "xentoollog_external.h"
+
static const char *libxl_tapif_script(libxl__gc *gc)
{
#if defined(__linux__) || defined(__FreeBSD__)
@@ -49,6 +51,10 @@ static int libxl__create_qemu_logfile(libxl__gc *gc, char *name)
char *logfile;
int rc, logfile_w;

+ logfile_w = xtl_logger_create_external(name);
+ if (logfile_w >= 0)
+ return logfile_w;
+
rc = libxl_create_logfile(CTX, name, &logfile);
if (rc) return rc;

diff --git a/tools/xl/xl_utils.c b/tools/xl/xl_utils.c
index b0d23b2..949d281 100644
--- a/tools/xl/xl_utils.c
+++ b/tools/xl/xl_utils.c
@@ -27,6 +27,8 @@
#include "xl.h"
#include "xl_utils.h"

+#include "../libs/light/xentoollog_external.h"
+
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
@@ -268,14 +270,16 @@ int do_daemonize(const char *name, const char *pidfile)

postfork();

- ret = libxl_create_logfile(ctx, name, &fullname);
- if (ret) {
- LOG("failed to open logfile %s: %s",fullname,strerror(errno));
- exit(-1);
+ logfile = xtl_logger_create_external((char *)name);
+ if (logfile < 0) {
+ ret = libxl_create_logfile(ctx, name, &fullname);
+ if (ret) {
+ LOG("failed to open logfile %s: %s",fullname,strerror(errno));
+ exit(-1);
+ }
+ CHK_SYSCALL(logfile = open(fullname, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644));
+ free(fullname);
}
-
- CHK_SYSCALL(logfile = open(fullname, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644));
- free(fullname);
assert(logfile >= 3);

CHK_SYSCALL(nullfd = open("/dev/null", O_RDONLY));
19 changes: 19 additions & 0 deletions pkg/xen-tools/patches-4.19.0/09-enable-kvm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/tools/Makefile.orig
+++ b/tools/Makefile
@@ -232,7 +232,7 @@
virtfs='' ; \
fi ; \
PKG_CONFIG_PATH=$(XEN_ROOT)/tools/pkg-config$${PKG_CONFIG_PATH:+:$${PKG_CONFIG_PATH}} \
- $$source/configure --enable-xen --target-list=i386-softmmu \
+ $$source/configure --enable-xen --target-list=i386-softmmu,$$(uname -m)-softmmu \
$(QEMU_XEN_ENABLE_DEBUG) \
$$enable_trace_backend \
--prefix=$(prefix) \
@@ -251,7 +251,6 @@
--mandir=$(LIBEXEC)/share/man \
--libexecdir=$(LIBEXEC)/libexec \
--firmwarepath=$(LIBEXEC)/share/qemu-firmware \
- --disable-kvm \
--disable-docs \
--disable-guest-agent \
--python=$(PYTHON) \
76 changes: 76 additions & 0 deletions pkg/xen-tools/patches-4.19.0/10-bridge-helper-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/tools/qemu-xen/net/tap.c b/tools/qemu-xen/net/tap.c
index 1bf085d..1887c4a 100644
--- a/tools/qemu-xen/net/tap.c
+++ b/tools/qemu-xen/net/tap.c
@@ -63,7 +63,7 @@ typedef struct TAPState {
Notifier exit;
} TAPState;

-static void launch_script(const char *setup_script, const char *ifname,
+static void launch_script(const char *setup_script, const char *ifname, const char *bridge,
int fd, Error **errp);

static void tap_send(void *opaque);
@@ -323,7 +323,7 @@ static void tap_exit_notify(Notifier *notifier, void *data)
Error *err = NULL;

if (s->down_script[0]) {
- launch_script(s->down_script, s->down_script_arg, s->fd, &err);
+ launch_script(s->down_script, s->down_script_arg, "bn1", s->fd, &err);
if (err) {
error_report_err(err);
}
@@ -431,7 +431,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
return s;
}

-static void launch_script(const char *setup_script, const char *ifname,
+static void launch_script(const char *setup_script, const char *ifname, const char *bridge,
int fd, Error **errp)
{
int pid, status;
@@ -456,6 +456,7 @@ static void launch_script(const char *setup_script, const char *ifname,
parg = args;
*parg++ = (char *)setup_script;
*parg++ = (char *)ifname;
+ *parg++ = (char *)bridge;
*parg = NULL;
execv(setup_script, args);
_exit(1);
@@ -648,8 +649,8 @@ int net_init_bridge(const Netdev *netdev, const char *name,
}

static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
- const char *setup_script, char *ifname,
- size_t ifname_sz, int mq_required, Error **errp)
+ const char *setup_script, char *ifname,
+ size_t ifname_sz, const char *bridge, int mq_required, Error **errp)
{
Error *err = NULL;
int fd, vnet_hdr_required;
@@ -671,7 +672,7 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
if (setup_script &&
setup_script[0] != '\0' &&
strcmp(setup_script, "no") != 0) {
- launch_script(setup_script, ifname, fd, &err);
+ launch_script(setup_script, ifname, bridge, fd, &err);
if (err) {
error_propagate(errp, err);
close(fd);
@@ -1003,8 +1004,14 @@ free_fail:
}

for (i = 0; i < queues; i++) {
- fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
- ifname, sizeof ifname, queues > 1, errp);
+
+ if(tap->br == NULL)
+ fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
+ ifname, sizeof ifname, "bn1" , queues > 1, errp);
+ else
+ fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
+ ifname, sizeof ifname, tap->br , queues > 1, errp);
+
if (fd == -1) {
return -1;
}
14 changes: 14 additions & 0 deletions pkg/xen-tools/patches-4.19.0/11-char-socket-revert.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/tools/qemu-xen/chardev/char-socket.c b/tools/qemu-xen/chardev/char-socket.c
index 8c58532..e816841 100644
--- a/tools/qemu-xen/chardev/char-socket.c
+++ b/tools/qemu-xen/chardev/char-socket.c
@@ -125,8 +125,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)

if (ret < 0 && errno != EAGAIN) {
if (tcp_chr_read_poll(chr) <= 0) {
- /* Perform disconnect and return error. */
tcp_chr_disconnect_locked(chr);
+ return len;
} /* else let the read handler finish it properly */
}

Loading

0 comments on commit 227db95

Please sign in to comment.