qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD
PATCH 1/1 qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD
qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD
Signed-off-by Brad Smith <[email protected]>
--- qga/commands-bsd.c | 19 +++++++++++++------ qga/commands-common.h | 12 +++++++----- qga/commands-posix.c | 4 ++-- qga/qapi-schema.json | 12 ++++++------ 4 files changed, 28 insertions(+), 19 deletions(-)
qga/commands-bsd.c +13 -6
@@ -28,12 +28,20 @@#include <net/ethernet.h> #endif #include <paths.h> +#ifdef __FreeBSD__ +#include <ufs/ffs/fs.h> +#endif + +#ifdef __NetBSD__ +typedef struct statvfs bsd_fsinfo_t ; +#else +typedef struct statfs bsd_fsinfo_t ; +#endif -#if defined(CONFIG_FSFREEZE ) || defined(CONFIG_FSTRIM ) || defined(__FreeBSD__)bool build_fs_mount_list (FsMountList *mounts,Error **errp) {FsMount *mount; -struct statfs *mntbuf, *mntp; +bsd_fsinfo_t *mntbuf, *mntp;struct stat statbuf;int i, count, ret;
@@ -57,16 +65,17 @@ bool build_fs_mount_list(FsMountList *mounts, Error **errp) mount->dirname =g_strdup (mntp->f_mntonname); mount->devtype =g_strdup (mntp->f_fstypename); mount->fromname =g_strdup (mntp->f_mntfromname); + mount->dev = statbuf.st_dev; mount->devmajor =major (mount->dev); mount->devminor =minor (mount->dev); +#ifdef CONFIG_FSFREEZE mount->fsid = mntp->f_fsid; - mount->dev = statbuf.st_dev; +#endif QTAILQ_INSERT_TAIL (mounts, mount, next); }return true; } -#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */ #if defined(CONFIG_FSFREEZE )static int ufssuspend_fd =-1 ;
@@ -181,7 +190,6 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned char *buf, }#endif /* HAVE_GETIFADDRS */ -#if defined(__FreeBSD__)static GuestFilesystemInfo *build_guest_fsinfo (struct FsMount *mount) {GuestFilesystemInfo *fs =g_new0 (GuestFilesystemInfo,1 );
@@ -228,4 +236,3 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)free_fs_mount_list (&mounts);return ret; } -#endif /* __FreeBSD__ */
qga/commands-common.h +7 -5
@@ -18,17 +18,19 @@#endif /* __linux__ */ #ifdef __FreeBSD__ -#include <ufs/ffs/fs.h> +#include <sys/mount.h> #endif /* __FreeBSD__ */ -#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) +#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) || defined(CONFIG_BSD) typedef struct FsMount { char *dirname; char *devtype; unsigned int devmajor, devminor; -#if defined(__FreeBSD__) - dev_t dev; +#ifdef __FreeBSD__ fsid_t fsid; +#endif +#ifdef CONFIG_BSD + dev_t dev; char *fromname; #endif QTAILQ_ENTRY(FsMount) next;
@@ -38,7 +40,7 @@ typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;bool build_fs_mount_list (FsMountList *mounts,Error **errp);void free_fs_mount_list (FsMountList *mounts); -#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */ +#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM || CONFIG_BSD */ #if defined(CONFIG_FSFREEZE ) int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints,
qga/commands-posix.c +2 -2
@@ -718,7 +718,7 @@ void qmp_guest_file_flush(int64_t handle, Error **errp) } } -#if defined(CONFIG_FSFREEZE ) || defined(CONFIG_FSTRIM ) +#if defined(CONFIG_FSFREEZE ) || defined(CONFIG_FSTRIM ) || defined(CONFIG_BSD )void free_fs_mount_list (FsMountList *mounts) {FsMount *mount, *temp;
@@ -731,7 +731,7 @@ void free_fs_mount_list(FsMountList *mounts)QTAILQ_REMOVE (mounts, mount, next);g_free (mount->dirname);g_free (mount->devtype); -#if defined(__FreeBSD__) +#ifdef CONFIG_BSD g_free (mount->fromname);#endif g_free (mount);
qga/qapi-schema.json +6 -6
@@ -874,7 +874,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', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @GuestPCIAddress:
@@ -892,7 +892,7 @@ { 'struct': 'GuestPCIAddress', 'data': {'domain': 'int', 'bus': 'int', 'slot': 'int', 'function': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @GuestCCWAddress:
@@ -912,7 +912,7 @@ 'ssid': 'int', 'subchno': 'int', 'devno': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @GuestDiskAddress:
@@ -942,7 +942,7 @@ 'bus': 'int', 'target': 'int', 'unit': 'int', '*serial': 'str', '*dev': 'str', '*ccw-address': 'GuestCCWAddress'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @GuestNVMeSmart:
@@ -1063,7 +1063,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', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @guest-get-fsinfo:
@@ -1077,7 +1077,7 @@ ## { 'command': 'guest-get-fsinfo', 'returns': ['GuestFilesystemInfo'], - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } ## # @guest-set-user-password:
Signature · 1 line
2.55.0
Quoted 9 lines · Brad Smith
qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD
Signed-off-by Brad Smith <[email protected]>--- qga/commands-bsd.c | 19 +++++++++++++------ qga/commands-common.h | 12 +++++++----- qga/commands-posix.c | 4 ++-- qga/qapi-schema.json | 12 ++++++------ 4 files changed, 28 insertions(+), 19 deletions(-)
Look reasonable and does not introduce regressions to the FreeBSD implementation, so:
Reviewed-by Roman Bogorodskiy <[email protected]>
Kostiantyn Kostiuk
Reviewed-byReviewed-by Kostiantyn Kostiuk <[email protected]>
Quoted 18 lines · Roman Bogorodskiy
Quoted 9 lines · Brad Smith
qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD
Signed-off-by Brad Smith <[email protected]>--- qga/commands-bsd.c | 19 +++++++++++++------ qga/commands-common.h | 12 +++++++----- qga/commands-posix.c | 4 ++-- qga/qapi-schema.json | 12 ++++++------ 4 files changed, 28 insertions(+), 19 deletions(-)Look reasonable and does not introduce regressions to the FreeBSD implementation, so:
Reviewed-by Roman Bogorodskiy <[email protected]>