On Wed, Oct 02, 2024 at 10:06:46PM -0400, Brad Smith wrote: > Here is an update to QEMU 9.1.0. > > > https://wiki.qemu.org/ChangeLog/9.1
An updated diff for 9.1.1 and added a regression fix for qga. Index: Makefile =================================================================== RCS file: /cvs/ports/emulators/qemu/Makefile,v retrieving revision 1.242 diff -u -p -u -p -r1.242 Makefile --- Makefile 26 Jul 2024 11:49:01 -0000 1.242 +++ Makefile 28 Oct 2024 02:24:29 -0000 @@ -6,7 +6,7 @@ USE_NOBTCFI= Yes COMMENT-main= multi system emulator COMMENT-ga= QEMU guest agent -VERSION= 9.0.2 +VERSION= 9.1.1 DISTNAME= qemu-${VERSION} CATEGORIES= emulators SITES= https://download.qemu.org/ @@ -70,8 +70,8 @@ LIB_DEPENDS-ga= ${LIB_DEPENDS} MAKE_ENV= V=1 FAKE_FLAGS= qemu_confdir=${PREFIX}/share/examples/qemu -CFLAGS+= -I${LOCALBASE}/include -I${X11BASE}/include -LDFLAGS+= -L${LOCALBASE}/lib -L${X11BASE}/lib +CFLAGS+= -I${LOCALBASE}/include +LDFLAGS+= -L${LOCALBASE}/lib # until the system headers are fixed properly. CFLAGS+= -Wno-redundant-decls Index: distinfo =================================================================== RCS file: /cvs/ports/emulators/qemu/distinfo,v retrieving revision 1.75 diff -u -p -u -p -r1.75 distinfo --- distinfo 26 Jul 2024 11:49:01 -0000 1.75 +++ distinfo 28 Oct 2024 02:24:29 -0000 @@ -1,2 +1,2 @@ -SHA256 (qemu-9.0.2.tar.xz) = qMP1lq7Olto7AMr7dLqvoNFFFer7jtHuP39cLQ6/ArY= -SIZE (qemu-9.0.2.tar.xz) = 132387528 +SHA256 (qemu-9.1.1.tar.xz) = fcD52lSR/0SVAPMxAGOja2GfI27kVwb9CEbrN9S7qIk= +SIZE (qemu-9.1.1.tar.xz) = 132584840 Index: patches/patch-contrib_plugins_Makefile =================================================================== RCS file: patches/patch-contrib_plugins_Makefile diff -N patches/patch-contrib_plugins_Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-contrib_plugins_Makefile 28 Oct 2024 02:24:29 -0000 @@ -0,0 +1,18 @@ +- contrib/plugins: ensure build does not pick up a system copy of plugin header + +Index: contrib/plugins/Makefile +--- contrib/plugins/Makefile.orig ++++ contrib/plugins/Makefile +@@ -41,9 +41,10 @@ SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$( + + # The main QEMU uses Glib extensively so it is perfectly fine to use it + # in plugins (which many example do). +-PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0) +-PLUGIN_CFLAGS += -fPIC -Wall ++GLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0) + PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu ++PLUGIN_CFLAGS += $(GLIB_CFLAGS) ++PLUGIN_CFLAGS += -fPIC -Wall + + # Helper that honours V=1 so we get some output when compiling + quiet-@ = $(if $(V),,@$(if $1,printf " %-7s %s\n" "$(strip $1)" "$(strip $2)" && )) Index: patches/patch-meson_build =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-meson_build,v retrieving revision 1.13 diff -u -p -u -p -r1.13 patch-meson_build --- patches/patch-meson_build 28 May 2024 13:57:37 -0000 1.13 +++ patches/patch-meson_build 28 Oct 2024 02:24:29 -0000 @@ -4,7 +4,7 @@ Index: meson.build --- meson.build.orig +++ meson.build -@@ -2156,7 +2156,7 @@ config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_ +@@ -2259,7 +2259,7 @@ config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_ config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) @@ -13,7 +13,7 @@ Index: meson.build config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) -@@ -4226,9 +4226,6 @@ else +@@ -4300,9 +4300,6 @@ else summary_info += {'Objective-C compiler': false} endif option_cflags = (get_option('debug') ? ['-g'] : []) Index: patches/patch-qga_commands-bsd_c =================================================================== RCS file: patches/patch-qga_commands-bsd_c diff -N patches/patch-qga_commands-bsd_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-qga_commands-bsd_c 28 Oct 2024 02:24:29 -0000 @@ -0,0 +1,307 @@ +Adapted from https://github.com/aborche/qemu-guest-agent + +Adds support for "guest-get-fsinfo" and "guest-get-vcpus" + +Index: qga/commands-bsd.c +--- qga/commands-bsd.c.orig ++++ qga/commands-bsd.c +@@ -11,10 +11,9 @@ + */ + + #include "qemu/osdep.h" ++#include "qapi/error.h" + #include "qga-qapi-commands.h" + #include "qapi/qmp/qerror.h" +-#include "qapi/error.h" +-#include "qemu/queue.h" + #include "commands-common.h" + #include <sys/ioctl.h> + #include <sys/param.h> +@@ -28,6 +27,8 @@ + #include <net/ethernet.h> + #endif + #include <paths.h> ++#include <sys/sysctl.h> ++#include <sys/statvfs.h> + + #if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) + bool build_fs_mount_list(FsMountList *mounts, Error **errp) +@@ -179,3 +180,278 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned c + return true; + } + #endif /* HAVE_GETIFADDRS */ ++ ++GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) ++{ ++ GuestLogicalProcessorList *head, **tail; ++ int64_t current; ++ long sc_max; ++ Error *local_err = NULL; ++ int Query[2]; ++ int NumCpu = 0; ++ size_t Length = sizeof(NumCpu); ++ ++ Query[0] = CTL_HW; ++#ifdef HW_NCPUONLINE ++ Query[1] = HW_NCPUONLINE; ++#else ++ Query[1] = HW_NCPU; ++#endif ++ ++ current = 0; ++ head = NULL; ++ tail = &head; ++ if (sysctl(Query, 2, &NumCpu, &Length, NULL, 0) == -1) { ++ error_setg(errp, "sysctl get CTL_HW.HW_NCPU failed"); ++ } ++ sc_max = NumCpu; ++ ++ while (local_err == NULL && current < sc_max) { ++ GuestLogicalProcessor *vcpu; ++ int64_t id = current++; ++ vcpu = g_malloc0(sizeof *vcpu); ++ vcpu->logical_id = id; ++ vcpu->has_can_offline = false; /* lolspeak ftw */ ++ vcpu->online = true; ++ vcpu->can_offline = false; ++ QAPI_LIST_APPEND(tail, vcpu); ++ } ++ ++ if (local_err == NULL) { ++ /* there's no guest with zero VCPUs */ ++ g_assert(head != NULL); ++ return head; ++ } ++ ++ qapi_free_GuestLogicalProcessorList(head); ++ error_propagate(errp, local_err); ++ return NULL; ++} ++ ++typedef struct FsMount { ++ char *dirname; ++ char *devtype; ++ char *size; ++ char *used; ++ char *free; ++ char *load; ++ char *mntpoint; ++ unsigned int devmajor, devminor; ++ QTAILQ_ENTRY(FsMount) next; ++} FsMount; ++ ++typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; ++ ++static void free_fs_mount_list(FsMountList *mounts) ++{ ++ FsMount *mount, *temp; ++ ++ if (!mounts) { ++ return; ++ } ++ ++ QTAILQ_FOREACH_SAFE(mount, mounts, next, temp) { ++ QTAILQ_REMOVE(mounts, mount, next); ++ g_free(mount->dirname); ++ g_free(mount->devtype); ++ g_free(mount->size); ++ g_free(mount->used); ++ g_free(mount->free); ++ g_free(mount->load); ++ g_free(mount->mntpoint); ++ g_free(mount); ++ } ++} ++ ++static void build_fs_mount_list(FsMountList *mounts, Error **errp) ++{ ++ FsMount *mount; ++#ifdef __OpenBSD__ ++ char const *dfcmd = "/bin/df"; ++#else // defined(__OpenBSD__) ++ char const *dfcmd = "/bin/df -hT"; ++#endif // defined(__OpenBSD__) ++ ++ FILE *fp; ++ char *line = NULL; ++ size_t n; ++ int ret; ++ char dev_name[128], size[12], used[12], free[12], load[10], mounted[128]; ++#ifndef __OpenBSD__ ++ char fstype[12] = ""; ++#endif // !defined(__OpenBSD__) ++ ++ if ((fp = popen(dfcmd, "r")) == NULL) { ++ g_debug("Cannot open '%s'!!\n", dfcmd); ++ error_setg_errno(errp, errno, ++ "failed to create child process for command: %s", ++ dfcmd); ++ return; ++ } ++ ++ while (getline(&line, &n, fp) != -1) { ++ //g_debug("line '%s'", line); ++#ifdef __OpenBSD__ ++ ret = sscanf(line, "%127s%11s%11s%11s%9s%127s", ++ dev_name, size, used, free, load, mounted); ++#else // defined(__OpenBSD__) ++ ret = sscanf(line, "%127s%11s%11s%11s%11s%9s%127s", ++ dev_name, fstype, size, used, free, load, mounted); ++ //g_debug("ret %d, dev_name '%s', fstype '%s', size '%s', used '%s', free '%s', load '%s', mounted '%s'", ++ // ret, dev_name, fstype, size, used, free, load, mounted); ++#endif // defined(__OpenBSD__) ++ if (g_str_equal(dev_name, "Filesystem") ++#ifndef __OpenBSD__ ++ ||g_str_equal(fstype,"devfs") ++ ||g_str_equal(fstype,"procfs") ++ ||g_str_equal(fstype,"fdescfs") ++#endif // !defined(__OpenBSD__) ++ ) { ++ continue; ++ } ++ ++#ifdef __OpenBSD__ ++ if (ret < 6) { ++#else // defined(__OpenBSD__) ++ if (ret < 7) { ++#endif // defined(__OpenBSD__) ++ continue; ++ } ++ ++ mount = g_new0(FsMount, 1); ++ mount->dirname = g_strdup(dev_name); ++#ifndef __OpenBSD__ ++ mount->devtype = g_strdup(fstype); ++#endif // defined(__OpenBSD__) ++ mount->free = g_strdup(free); ++ mount->load = g_strdup(load); ++ mount->size = g_strdup(size); ++ mount->used = g_strdup(used); ++ mount->mntpoint = g_strdup(mounted); ++ mount->devmajor = 0; ++ mount->devminor = 0; ++ ++ QTAILQ_INSERT_TAIL(mounts, mount, next); ++ } ++ g_free(line); ++ ++ fclose(fp); ++} ++ ++#ifdef __OpenBSD__ ++static void add_type_fs_mount_list(FsMountList *mounts, Error **errp) ++{ ++ FILE *fp; ++ char const *mountcmd = "/sbin/mount"; ++ char *line = NULL; ++ size_t n; ++ int ret; ++ char mnt_fsname[128], mnt_dir[128], mnt_type[32], mnt_opts[128]; ++ struct FsMount *mount; ++ ++ // get mounts from mount command ++ if ((fp = popen(mountcmd, "r")) == NULL) { ++ g_debug("Cannot open '%s'!!\n", mountcmd); ++ error_setg_errno(errp, errno, "failed to create child process for command: %s", mountcmd); ++ return; ++ } ++ ++ // loop through mounts from mount command ++ while (getline(&line, &n, fp) != -1) { ++ //g_debug("line '%s'", line); ++ ++ ret = sscanf(line, "%127s on %127s type %31s (%127s)", ++ mnt_fsname, mnt_dir, mnt_type, mnt_opts); ++ //g_debug("ret %d, fsname '%s', dir '%s', type '%s', opts '%s'", ++ // ret, mnt_fsname, mnt_dir, mnt_type, mnt_opts); ++ ++ if (4 != ret || ++ '/' != mnt_fsname[0] || ++ '/' != mnt_dir[0] || ++ g_str_equal("smbfs", mnt_type) || ++ g_str_equal("cifs", mnt_type)) { ++ continue; ++ } ++ ++ // find mount in supplied mounts list and update device type ++ QTAILQ_FOREACH(mount, mounts, next) { ++ if (NULL == mount->devtype && g_str_equal(mount->dirname, mnt_fsname)) { ++ mount->devtype = g_strdup(mnt_type); ++ break; ++ } ++ } ++ } ++ g_free(line); ++ ++ fclose(fp); ++} ++#endif // defined(__OpenBSD__) ++ ++/* Return a list of the disk device(s)' info which @mount lies on */ ++static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount, ++ Error **errp) ++{ ++ GuestFilesystemInfo *fs = g_malloc0(sizeof(*fs)); ++ struct statvfs buf; ++ unsigned long used, nonroot_total, fr_size; ++ ++ fs->name = g_strdup(mount->dirname); ++ fs->mountpoint = g_strdup(mount->mntpoint); ++ fs->type = g_strdup(mount->devtype); ++ ++ if (statvfs(fs->mountpoint, &buf) == 0) { ++ fr_size = buf.f_frsize; ++ used = buf.f_blocks - buf.f_bfree; ++ nonroot_total = used + buf.f_bavail; ++ fs->used_bytes = used * fr_size; ++ fs->total_bytes = nonroot_total * fr_size; ++ ++ fs->has_total_bytes = true; ++ fs->has_used_bytes = true; ++ } ++ ++ return fs; ++} ++ ++GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) ++{ ++ FsMountList mounts; ++ struct FsMount *mount; ++ GuestFilesystemInfoList *new, *ret = NULL; ++ Error *local_err = NULL; ++ ++ QTAILQ_INIT(&mounts); ++ ++ g_debug("Entering to guest_get_fsinfo"); ++ build_fs_mount_list(&mounts, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return NULL; ++ } ++ ++#ifdef __OpenBSD__ ++ add_type_fs_mount_list(&mounts, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return NULL; ++ } ++#endif // defined(__OpenBSD__) ++ ++ QTAILQ_FOREACH(mount, &mounts, next) { ++ //g_debug("Building guest fsinfo for '%s'", mount->dirname); ++ //g_debug("Devtype '%s'", mount->devtype); ++ new = g_malloc0(sizeof(*ret)); ++ new->value = build_guest_fsinfo(mount, &local_err); ++ new->next = ret; ++ ret = new; ++ if (local_err) { ++ error_propagate(errp, local_err); ++ qapi_free_GuestFilesystemInfoList(ret); ++ ret = NULL; ++ break; ++ } ++ } ++ ++ free_fs_mount_list(&mounts); ++ return ret; ++} Index: patches/patch-qga_commands-posix_c =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-qga_commands-posix_c,v retrieving revision 1.10 diff -u -p -u -p -r1.10 patch-qga_commands-posix_c --- patches/patch-qga_commands-posix_c 28 May 2024 13:57:37 -0000 1.10 +++ patches/patch-qga_commands-posix_c 28 Oct 2024 02:24:29 -0000 @@ -1,416 +1,14 @@ -Adapted from https://github.com/aborche/qemu-guest-agent - -Adds support for "guest-get-fsinfo" and "guest-get-vcpus" +qemu-ga: Fix a SIGSEGV on guest-set-time command Index: qga/commands-posix.c --- qga/commands-posix.c.orig +++ qga/commands-posix.c -@@ -59,6 +59,11 @@ - #endif - #endif - -+#ifdef __OpenBSD__ -+#include <sys/sysctl.h> -+#include <sys/statvfs.h> -+#endif -+ - static void ga_wait_child(pid_t pid, int *status, Error **errp) - { - pid_t rpid; -@@ -2750,7 +2755,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp - return head; - } - --#else /* defined(__linux__) */ -+#elif defined(CONFIG_BSD) - - void qmp_guest_suspend_disk(Error **errp) - { -@@ -2769,10 +2774,99 @@ void qmp_guest_suspend_hybrid(Error **errp) - - GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) - { -+ int64_t current; -+ GuestLogicalProcessorList *head, **tail; -+ long sc_max; -+ Error *local_err = NULL; -+ int Query[2]; -+ int NumCpu = 0; -+ size_t Length = sizeof(NumCpu); -+ -+ Query[0] = CTL_HW; -+#ifdef HW_NCPUONLINE -+ Query[1] = HW_NCPUONLINE; -+#else -+ Query[1] = HW_NCPU; -+#endif -+ -+ current = 0; -+ head = NULL; -+ tail = &head; -+ if (sysctl(Query, 2, &NumCpu, &Length, NULL, 0) == -1) { -+ error_setg(errp, "sysctl get CTL_HW.HW_NCPU failed"); -+ } -+ sc_max = NumCpu; -+ -+ while (local_err == NULL && current < sc_max) { -+ GuestLogicalProcessor *vcpu; -+ int64_t id = current++; -+ vcpu = g_malloc0(sizeof *vcpu); -+ vcpu->logical_id = id; -+ vcpu->has_can_offline = false; /* lolspeak ftw */ -+ vcpu->online = true; -+ vcpu->can_offline = false; -+ QAPI_LIST_APPEND(tail, vcpu); -+ } -+ -+ if (local_err == NULL) { -+ /* there's no guest with zero VCPUs */ -+ g_assert(head != NULL); -+ return head; -+ } -+ -+ qapi_free_GuestLogicalProcessorList(head); -+ error_propagate(errp, local_err); -+ return NULL; -+} -+ -+int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) -+{ - error_setg(errp, QERR_UNSUPPORTED); -+ return -1; -+} -+ -+GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); - return NULL; - } - -+GuestMemoryBlockResponseList * -+qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+ return NULL; -+} -+ -+GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+ return NULL; -+} -+ -+#else /* defined(CONFIG_BSD) */ -+ -+void qmp_guest_suspend_disk(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+} -+ -+void qmp_guest_suspend_ram(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+} -+ -+void qmp_guest_suspend_hybrid(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+} -+ -+GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) -+{ -+ error_setg(errp, QERR_UNSUPPORTED); -+ return NULL; -+} -+ - int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) - { - error_setg(errp, QERR_UNSUPPORTED); -@@ -3067,11 +3161,245 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inter - - #if !defined(CONFIG_FSFREEZE) - -+#ifdef CONFIG_BSD -+typedef struct FsMount { -+ char *dirname; -+ char *devtype; -+ char *size; -+ char *used; -+ char *free; -+ char *load; -+ char *mntpoint; -+ unsigned int devmajor, devminor; -+ QTAILQ_ENTRY(FsMount) next; -+} FsMount; -+ -+typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; -+ -+static void free_fs_mount_list(FsMountList *mounts) -+{ -+ FsMount *mount, *temp; -+ -+ if (!mounts) { -+ return; -+ } -+ -+ QTAILQ_FOREACH_SAFE(mount, mounts, next, temp) { -+ QTAILQ_REMOVE(mounts, mount, next); -+ g_free(mount->dirname); -+ g_free(mount->devtype); -+ g_free(mount->size); -+ g_free(mount->used); -+ g_free(mount->free); -+ g_free(mount->load); -+ g_free(mount->mntpoint); -+ g_free(mount); -+ } -+} -+ -+static void build_fs_mount_list(FsMountList *mounts, Error **errp) -+{ -+ FsMount *mount; -+#ifdef __OpenBSD__ -+ char const *dfcmd = "/bin/df"; -+#else // defined(__OpenBSD__) -+ char const *dfcmd = "/bin/df -hT"; -+#endif // defined(__OpenBSD__) -+ -+ FILE *fp; -+ char *line = NULL; -+ size_t n; -+ int ret; -+ char dev_name[128], size[12], used[12], free[12], load[10], mounted[128]; -+#ifndef __OpenBSD__ -+ char fstype[12] = ""; -+#endif // !defined(__OpenBSD__) -+ -+ if ((fp = popen(dfcmd, "r")) == NULL) { -+ g_debug("Cannot open '%s'!!\n", dfcmd); -+ error_setg_errno(errp, errno, -+ "failed to create child process for command: %s", -+ dfcmd); -+ return; -+ } -+ -+ while (getline(&line, &n, fp) != -1) { -+ //g_debug("line '%s'", line); -+#ifdef __OpenBSD__ -+ ret = sscanf(line, "%127s%11s%11s%11s%9s%127s", -+ dev_name, size, used, free, load, mounted); -+#else // defined(__OpenBSD__) -+ ret = sscanf(line, "%127s%11s%11s%11s%11s%9s%127s", -+ dev_name, fstype, size, used, free, load, mounted); -+ //g_debug("ret %d, dev_name '%s', fstype '%s', size '%s', used '%s', free '%s', load '%s', mounted '%s'", -+ // ret, dev_name, fstype, size, used, free, load, mounted); -+#endif // defined(__OpenBSD__) -+ if (g_str_equal(dev_name, "Filesystem") -+#ifndef __OpenBSD__ -+ ||g_str_equal(fstype,"devfs") -+ ||g_str_equal(fstype,"procfs") -+ ||g_str_equal(fstype,"fdescfs") -+#endif // !defined(__OpenBSD__) -+ ) { -+ continue; -+ } -+ -+#ifdef __OpenBSD__ -+ if (ret < 6) { -+#else // defined(__OpenBSD__) -+ if (ret < 7) { -+#endif // defined(__OpenBSD__) -+ continue; -+ } -+ -+ mount = g_new0(FsMount, 1); -+ mount->dirname = g_strdup(dev_name); -+#ifndef __OpenBSD__ -+ mount->devtype = g_strdup(fstype); -+#endif // defined(__OpenBSD__) -+ mount->free = g_strdup(free); -+ mount->load = g_strdup(load); -+ mount->size = g_strdup(size); -+ mount->used = g_strdup(used); -+ mount->mntpoint = g_strdup(mounted); -+ mount->devmajor = 0; -+ mount->devminor = 0; -+ -+ QTAILQ_INSERT_TAIL(mounts, mount, next); -+ } -+ g_free(line); -+ -+ fclose(fp); -+} -+ -+#ifdef __OpenBSD__ -+ -+static void add_type_fs_mount_list(FsMountList *mounts, Error **errp) -+{ -+ FILE *fp; -+ char const *mountcmd = "/sbin/mount"; -+ char *line = NULL; -+ size_t n; -+ int ret; -+ char mnt_fsname[128], mnt_dir[128], mnt_type[32], mnt_opts[128]; -+ struct FsMount *mount; -+ -+ // get mounts from mount command -+ if ((fp = popen(mountcmd, "r")) == NULL) { -+ g_debug("Cannot open '%s'!!\n", mountcmd); -+ error_setg_errno(errp, errno, "failed to create child process for command: %s", mountcmd); -+ return; -+ } -+ -+ // loop through mounts from mount command -+ while (getline(&line, &n, fp) != -1) { -+ //g_debug("line '%s'", line); -+ -+ ret = sscanf(line, "%127s on %127s type %31s (%127s)", -+ mnt_fsname, mnt_dir, mnt_type, mnt_opts); -+ //g_debug("ret %d, fsname '%s', dir '%s', type '%s', opts '%s'", -+ // ret, mnt_fsname, mnt_dir, mnt_type, mnt_opts); -+ -+ if (4 != ret || -+ '/' != mnt_fsname[0] || -+ '/' != mnt_dir[0] || -+ g_str_equal("smbfs", mnt_type) || -+ g_str_equal("cifs", mnt_type)) { -+ continue; -+ } -+ -+ // find mount in supplied mounts list and update device type -+ QTAILQ_FOREACH(mount, mounts, next) { -+ if (NULL == mount->devtype && g_str_equal(mount->dirname, mnt_fsname)) { -+ mount->devtype = g_strdup(mnt_type); -+ break; -+ } -+ } -+ } -+ g_free(line); -+ -+ fclose(fp); -+} -+ -+#endif // defined(__OpenBSD__) -+ -+/* Return a list of the disk device(s)' info which @mount lies on */ -+static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount, -+ Error **errp) -+{ -+ GuestFilesystemInfo *fs = g_malloc0(sizeof(*fs)); -+ struct statvfs buf; -+ unsigned long used, nonroot_total, fr_size; -+ -+ fs->name = g_strdup(mount->dirname); -+ fs->mountpoint = g_strdup(mount->mntpoint); -+ fs->type = g_strdup(mount->devtype); -+ -+ if (statvfs(fs->mountpoint, &buf) == 0) { -+ fr_size = buf.f_frsize; -+ used = buf.f_blocks - buf.f_bfree; -+ nonroot_total = used + buf.f_bavail; -+ fs->used_bytes = used * fr_size; -+ fs->total_bytes = nonroot_total * fr_size; -+ -+ fs->has_total_bytes = true; -+ fs->has_used_bytes = true; -+ } -+ -+ //g_free(devpath); -+ -+ return fs; -+} -+ - GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) - { -+ FsMountList mounts; -+ struct FsMount *mount; -+ GuestFilesystemInfoList *new, *ret = NULL; -+ Error *local_err = NULL; -+ -+ QTAILQ_INIT(&mounts); -+ -+ g_debug("Entering to guest_get_fsinfo"); -+ build_fs_mount_list(&mounts, &local_err); -+ if (local_err) { -+ error_propagate(errp, local_err); -+ return NULL; -+ } -+ -+#ifdef __OpenBSD__ -+ add_type_fs_mount_list(&mounts, &local_err); -+ if (local_err) { -+ error_propagate(errp, local_err); -+ return NULL; -+ } -+#endif // defined(__OpenBSD__) -+ -+ QTAILQ_FOREACH(mount, &mounts, next) { -+ //g_debug("Building guest fsinfo for '%s'", mount->dirname); -+ //g_debug("Devtype '%s'", mount->devtype); -+ new = g_malloc0(sizeof(*ret)); -+ new->value = build_guest_fsinfo(mount, &local_err); -+ new->next = ret; -+ ret = new; -+ if (local_err) { -+ error_propagate(errp, local_err); -+ qapi_free_GuestFilesystemInfoList(ret); -+ ret = NULL; -+ break; -+ } -+ } -+ -+ free_fs_mount_list(&mounts); -+ return ret; -+} -+#else -+GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) -+{ - error_setg(errp, QERR_UNSUPPORTED); - return NULL; - } -+#endif /* CONFIG_BSD */ - - GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp) - { -@@ -3137,12 +3465,21 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs) - { - #if !defined(__linux__) - { -+#ifdef CONFIG_BSD - const char *list[] = { - "guest-suspend-disk", "guest-suspend-ram", -+ "guest-suspend-hybrid", "guest-set-vcpus", -+ "guest-get-memory-blocks", "guest-set-memory-blocks", -+ "guest-get-memory-block-size", "guest-get-memory-block-info", -+ NULL}; -+#else -+ const char *list[] = { -+ "guest-suspend-disk", "guest-suspend-ram", - "guest-suspend-hybrid", "guest-get-vcpus", "guest-set-vcpus", - "guest-get-memory-blocks", "guest-set-memory-blocks", - "guest-get-memory-block-size", "guest-get-memory-block-info", - NULL}; -+#endif /* CONFIG_BSD */ - char **p = (char **)list; - - while (*p) { -@@ -3158,11 +3495,19 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs) - - #if !defined(CONFIG_FSFREEZE) - { -+#ifdef CONFIG_BSD - const char *list[] = { -+ "guest-fsfreeze-status", -+ "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list", -+ "guest-fsfreeze-thaw", -+ "guest-get-disks", NULL}; -+#else -+ const char *list[] = { - "guest-get-fsinfo", "guest-fsfreeze-status", - "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list", - "guest-fsfreeze-thaw", "guest-get-fsinfo", - "guest-get-disks", NULL}; -+#endif /* CONFIG_BSD */ - char **p = (char **)list; - - while (*p) { +@@ -85,7 +85,7 @@ static ssize_t ga_pipe_read_str(int fd[2], char **str) + *str = g_realloc(*str, len + n + 1); + memcpy(*str + len, buf, n); + len += n; +- *str[len] = '\0'; ++ (*str)[len] = '\0'; + } + close(fd[0]); + fd[0] = -1; Index: patches/patch-qga_main_c =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-qga_main_c,v retrieving revision 1.8 diff -u -p -u -p -r1.8 patch-qga_main_c --- patches/patch-qga_main_c 26 Feb 2024 13:30:18 -0000 1.8 +++ patches/patch-qga_main_c 28 Oct 2024 02:24:29 -0000 @@ -15,7 +15,7 @@ Index: qga/main.c #define QGA_STATE_RELATIVE_DIR "run" #else #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0" -@@ -1597,7 +1601,11 @@ int main(int argc, char **argv) +@@ -1601,7 +1605,11 @@ int main(int argc, char **argv) } if (config->method == NULL) { Index: patches/patch-qga_qapi-schema_json =================================================================== RCS file: patches/patch-qga_qapi-schema_json diff -N patches/patch-qga_qapi-schema_json --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-qga_qapi-schema_json 28 Oct 2024 02:24:29 -0000 @@ -0,0 +1,79 @@ +Adapted from https://github.com/aborche/qemu-guest-agent + +Adds support for "guest-get-fsinfo" and "guest-get-vcpus" + +Index: qga/qapi-schema.json +--- qga/qapi-schema.json.orig ++++ qga/qapi-schema.json +@@ -767,7 +767,7 @@ + 'data': {'logical-id': 'int', + 'online': 'bool', + '*can-offline': 'bool'}, +- 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } ++ 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_BSD'] } } + + ## + # @guest-get-vcpus: +@@ -783,7 +783,7 @@ + ## + { 'command': 'guest-get-vcpus', + 'returns': ['GuestLogicalProcessor'], +- 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } ++ 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_BSD'] } } + + ## + # @guest-set-vcpus: +@@ -879,7 +879,7 @@ + 'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata', + 'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi', + 'sas', 'mmc', 'virtual', 'file-backed-virtual', 'nvme' ], +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + + ## +@@ -898,7 +898,7 @@ + { 'struct': 'GuestPCIAddress', + 'data': {'domain': 'int', 'bus': 'int', + 'slot': 'int', 'function': 'int'}, +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + ## + # @GuestCCWAddress: +@@ -918,7 +918,7 @@ + 'ssid': 'int', + 'subchno': 'int', + 'devno': 'int'}, +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + ## + # @GuestDiskAddress: +@@ -948,7 +948,7 @@ + 'bus': 'int', 'target': 'int', 'unit': 'int', + '*serial': 'str', '*dev': 'str', + '*ccw-address': 'GuestCCWAddress'}, +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + ## + # @GuestNVMeSmart: +@@ -1068,7 +1068,7 @@ + 'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str', + '*used-bytes': 'uint64', '*total-bytes': 'uint64', + '*total-bytes-privileged': 'uint64', 'disk': ['GuestDiskAddress']}, +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + ## + # @guest-get-fsinfo: +@@ -1082,7 +1082,7 @@ + ## + { 'command': 'guest-get-fsinfo', + 'returns': ['GuestFilesystemInfo'], +- 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } ++ 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } + + ## + # @guest-set-user-password: Index: patches/patch-tcg_riscv_tcg-target_c_inc =================================================================== RCS file: patches/patch-tcg_riscv_tcg-target_c_inc diff -N patches/patch-tcg_riscv_tcg-target_c_inc --- patches/patch-tcg_riscv_tcg-target_c_inc 15 Jul 2024 11:13:29 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ -util/cpuinfo-riscv: Support OpenBSD signal frame -adc028428a6da5ea8d6a688085966a33be4c97c7 - -Index: tcg/riscv/tcg-target.c.inc ---- tcg/riscv/tcg-target.c.inc.orig -+++ tcg/riscv/tcg-target.c.inc -@@ -2116,7 +2116,14 @@ static void sigill_handler(int signo, siginfo_t *si, v - { - /* Skip the faulty instruction */ - ucontext_t *uc = (ucontext_t *)data; -+ -+#ifdef __linux__ - uc->uc_mcontext.__gregs[REG_PC] += 4; -+#elif defined(__OpenBSD__) -+ uc->sc_sepc += 4; -+#else -+# error Unsupported OS -+#endif - - got_sigill = 1; - } Index: patches/patch-util_cpuinfo-aarch64_c =================================================================== RCS file: patches/patch-util_cpuinfo-aarch64_c diff -N patches/patch-util_cpuinfo-aarch64_c --- patches/patch-util_cpuinfo-aarch64_c 15 Jul 2024 11:13:29 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,56 +0,0 @@ -util/cpuinfo-aarch64: Add OpenBSD support -ab089908b42f22e7edfa0d40db963c136ab35419 - -Index: util/cpuinfo-aarch64.c ---- util/cpuinfo-aarch64.c.orig -+++ util/cpuinfo-aarch64.c -@@ -20,6 +20,12 @@ - #ifdef CONFIG_DARWIN - # include <sys/sysctl.h> - #endif -+#ifdef __OpenBSD__ -+# include <machine/armreg.h> -+# include <machine/cpu.h> -+# include <sys/types.h> -+# include <sys/sysctl.h> -+#endif - - unsigned cpuinfo; - -@@ -71,6 +77,36 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi - info |= sysctl_for_bool("hw.optional.arm.FEAT_AES") * CPUINFO_AES; - info |= sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMULL; - info |= sysctl_for_bool("hw.optional.arm.FEAT_BTI") * CPUINFO_BTI; -+#endif -+#ifdef __OpenBSD__ -+ int mib[2]; -+ uint64_t isar0; -+ uint64_t pfr1; -+ size_t len; -+ -+ mib[0] = CTL_MACHDEP; -+ mib[1] = CPU_ID_AA64ISAR0; -+ len = sizeof(isar0); -+ if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) { -+ if (ID_AA64ISAR0_ATOMIC(isar0) >= ID_AA64ISAR0_ATOMIC_IMPL) { -+ info |= CPUINFO_LSE; -+ } -+ if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_BASE) { -+ info |= CPUINFO_AES; -+ } -+ if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_PMULL) { -+ info |= CPUINFO_PMULL; -+ } -+ } -+ -+ mib[0] = CTL_MACHDEP; -+ mib[1] = CPU_ID_AA64PFR1; -+ len = sizeof(pfr1); -+ if (sysctl(mib, 2, &pfr1, &len, NULL, 0) != -1) { -+ if (ID_AA64PFR1_BT(pfr1) >= ID_AA64PFR1_BT_IMPL) { -+ info |= CPUINFO_BTI; -+ } -+ } - #endif - - cpuinfo = info; Index: patches/patch-util_cpuinfo-ppc_c =================================================================== RCS file: patches/patch-util_cpuinfo-ppc_c diff -N patches/patch-util_cpuinfo-ppc_c --- patches/patch-util_cpuinfo-ppc_c 15 Jul 2024 11:13:29 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,54 +0,0 @@ -util/cpuinfo-ppc: Fix building on OpenBSD -272d3decc19aebe87955f4ec6d0c6cc8790471f1 - -Index: util/cpuinfo-ppc.c ---- util/cpuinfo-ppc.c.orig -+++ util/cpuinfo-ppc.c -@@ -6,11 +6,13 @@ - #include "qemu/osdep.h" - #include "host/cpuinfo.h" - --#include <asm/cputable.h> --#ifdef CONFIG_GETAUXVAL --# include <sys/auxv.h> --#else --# include "elf.h" -+#ifdef CONFIG_LINUX -+# include <asm/cputable.h> -+# ifdef CONFIG_GETAUXVAL -+# include <sys/auxv.h> -+# else -+# include "elf.h" -+# endif - #endif - - unsigned cpuinfo; -@@ -19,16 +21,17 @@ unsigned cpuinfo; - unsigned __attribute__((constructor)) cpuinfo_init(void) - { - unsigned info = cpuinfo; -- unsigned long hwcap, hwcap2; - - if (info) { - return info; - } - -- hwcap = qemu_getauxval(AT_HWCAP); -- hwcap2 = qemu_getauxval(AT_HWCAP2); - info = CPUINFO_ALWAYS; - -+#ifdef CONFIG_LINUX -+ unsigned long hwcap = qemu_getauxval(AT_HWCAP); -+ unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); -+ - /* Version numbers are monotonic, and so imply all lower versions. */ - if (hwcap2 & PPC_FEATURE2_ARCH_3_1) { - info |= CPUINFO_V3_1 | CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06; -@@ -58,6 +61,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi - } - } - } -+#endif - - cpuinfo = info; - return info; Index: pkg/PLIST-main =================================================================== RCS file: /cvs/ports/emulators/qemu/pkg/PLIST-main,v retrieving revision 1.17 diff -u -p -u -p -r1.17 PLIST-main --- pkg/PLIST-main 28 May 2024 13:57:38 -0000 1.17 +++ pkg/PLIST-main 28 Oct 2024 02:24:29 -0000 @@ -21,7 +21,6 @@ @bin bin/qemu-system-mips64 @bin bin/qemu-system-mips64el @bin bin/qemu-system-mipsel -@bin bin/qemu-system-nios2 @bin bin/qemu-system-or1k @bin bin/qemu-system-ppc @bin bin/qemu-system-ppc64 @@ -110,6 +109,7 @@ share/doc/qemu/devel/clocks.html share/doc/qemu/devel/code-of-conduct.html share/doc/qemu/devel/conflict-resolution.html share/doc/qemu/devel/control-flow-integrity.html +share/doc/qemu/devel/crypto.html share/doc/qemu/devel/decodetree.html share/doc/qemu/devel/docs.html share/doc/qemu/devel/ebpf_rss.html @@ -122,6 +122,7 @@ share/doc/qemu/devel/index-tcg.html share/doc/qemu/devel/index.html share/doc/qemu/devel/kconfig.html share/doc/qemu/devel/loads-stores.html +share/doc/qemu/devel/luks-detached-header.html share/doc/qemu/devel/maintainers.html share/doc/qemu/devel/memory.html share/doc/qemu/devel/migration/ @@ -134,6 +135,8 @@ share/doc/qemu/devel/migration/index.htm share/doc/qemu/devel/migration/main.html share/doc/qemu/devel/migration/mapped-ram.html share/doc/qemu/devel/migration/postcopy.html +share/doc/qemu/devel/migration/qpl-compression.html +share/doc/qemu/devel/migration/uadk-compression.html share/doc/qemu/devel/migration/vfio.html share/doc/qemu/devel/migration/virtio.html share/doc/qemu/devel/modules.html @@ -176,7 +179,10 @@ share/doc/qemu/interop/dbus-vmstate.html share/doc/qemu/interop/dbus.html share/doc/qemu/interop/index.html share/doc/qemu/interop/live-block-operations.html +share/doc/qemu/interop/nbd.html +share/doc/qemu/interop/parallels.html share/doc/qemu/interop/pr-helper.html +share/doc/qemu/interop/prl-xml.html share/doc/qemu/interop/qemu-qmp-ref.html share/doc/qemu/interop/qemu-storage-daemon-qmp-ref.html share/doc/qemu/interop/qmp-spec.html @@ -211,7 +217,10 @@ share/doc/qemu/specs/ppc-spapr-uv-hcalls share/doc/qemu/specs/ppc-spapr-xive.html share/doc/qemu/specs/ppc-xive.html share/doc/qemu/specs/pvpanic.html +share/doc/qemu/specs/rapl-msr.html +share/doc/qemu/specs/rocker.html share/doc/qemu/specs/sev-guest-firmware.html +share/doc/qemu/specs/spdm.html share/doc/qemu/specs/standard-vga.html share/doc/qemu/specs/tpm.html share/doc/qemu/specs/virt-ctlr.html @@ -255,6 +264,7 @@ share/doc/qemu/system/arm/vexpress.html share/doc/qemu/system/arm/virt.html share/doc/qemu/system/arm/xenpvh.html share/doc/qemu/system/arm/xlnx-versal-virt.html +share/doc/qemu/system/arm/xlnx-zynq.html share/doc/qemu/system/arm/xscale.html share/doc/qemu/system/authz.html share/doc/qemu/system/barrier.html @@ -363,6 +373,7 @@ share/doc/qemu/tools/qemu-nbd.html share/doc/qemu/tools/qemu-pr-helper.html share/doc/qemu/tools/qemu-storage-daemon.html share/doc/qemu/tools/qemu-trace-stap.html +share/doc/qemu/tools/qemu-vmsr-helper.html share/doc/qemu/tools/virtfs-proxy-helper.html share/doc/qemu/user/ share/doc/qemu/user/index.html @@ -413,6 +424,8 @@ share/qemu/edk2-i386-code.fd share/qemu/edk2-i386-secure-code.fd share/qemu/edk2-i386-vars.fd share/qemu/edk2-licenses.txt +share/qemu/edk2-riscv-code.fd +share/qemu/edk2-riscv-vars.fd share/qemu/edk2-x86_64-code.fd share/qemu/edk2-x86_64-secure-code.fd share/qemu/efi-e1000.rom