These APIs were an experimental feature for adding 9pfs disks to the
libguestfs appliance. It was never possible to use this without
hacking the qemu command line of the appliance to add such drives by
hand.
Note that for ABI reasons these APIs are not actually removed, they
have been changed so that they always return an error. These APIs
were actually hard-removed from all versions of RHEL.
See-also:
https://bugzilla.redhat.com/921710
---
daemon/9p.c | 153 +--------------------------
generator/actions_core.ml | 21 ----
generator/actions_core_deprecated.ml | 17 +++
tests/9p/test-9p.sh | 63 -----------
tests/Makefile.am | 3 -
5 files changed, 21 insertions(+), 236 deletions(-)
diff --git a/daemon/9p.c b/daemon/9p.c
index 9a3a5cfdf2..a0bc66539e 100644
--- a/daemon/9p.c
+++ b/daemon/9p.c
@@ -18,165 +18,20 @@
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-
-#include "ignore-value.h"
-
#include "daemon.h"
#include "actions.h"
-#define BUS_PATH "/sys/bus/virtio/drivers/9pnet_virtio"
-
-static void
-modprobe_9pnet_virtio (void)
-{
- /* Required with Linux 5.6 and maybe earlier kernels. For unclear
- * reasons the module is not an automatic dependency of the 9p
- * module so doesn't get loaded automatically.
- */
- ignore_value (command (NULL, NULL, "modprobe", "9pnet_virtio",
NULL));
-}
-
-/*
https://bugzilla.redhat.com/show_bug.cgi?id=714981#c1 */
char **
do_list_9p (void)
{
- CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r);
- DIR *dir;
-
- modprobe_9pnet_virtio ();
-
- dir = opendir (BUS_PATH);
- if (!dir) {
- perror ("opendir: " BUS_PATH);
- if (errno != ENOENT) {
- reply_with_perror ("opendir: " BUS_PATH);
- return NULL;
- }
-
- /* If this directory doesn't exist, it probably means that
- * the virtio driver isn't loaded. Don't return an error
- * in this case, but return an empty list.
- */
- if (end_stringsbuf (&r) == -1)
- return NULL;
-
- return take_stringsbuf (&r);
- }
-
- while (1) {
- struct dirent *d;
-
- errno = 0;
- d = readdir (dir);
- if (d == NULL) break;
-
- if (STRPREFIX (d->d_name, "virtio")) {
- CLEANUP_FREE char *mount_tag_path = NULL;
- if (asprintf (&mount_tag_path, BUS_PATH "/%s/mount_tag",
- d->d_name) == -1) {
- reply_with_perror ("asprintf");
- closedir (dir);
- return NULL;
- }
-
- /* A bit unclear, but it looks like the virtio transport allows
- * the mount tag length to be unlimited (or up to 65536 bytes).
- * See: linux/include/linux/virtio_9p.h
- */
- CLEANUP_FREE char *mount_tag = read_whole_file (mount_tag_path, NULL);
- if (mount_tag == 0)
- continue;
-
- if (add_string (&r, mount_tag) == -1) {
- closedir (dir);
- return NULL;
- }
- }
- }
-
- /* Check readdir didn't fail */
- if (errno != 0) {
- reply_with_perror ("readdir: " BUS_PATH);
- closedir (dir);
- return NULL;
- }
-
- /* Close the directory handle */
- if (closedir (dir) == -1) {
- reply_with_perror ("closedir: " BUS_PATH);
- return NULL;
- }
-
- /* Sort the tags. */
- if (r.size > 0)
- sort_strings (r.argv, r.size);
-
- /* NULL terminate the list */
- if (end_stringsbuf (&r) == -1)
- return NULL;
-
- return take_stringsbuf (&r);
+ reply_with_perror ("9p support was removed in libguestfs 1.48");
+ return NULL;
}
/* Takes optional arguments, consult optargs_bitmask. */
int
do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
{
- CLEANUP_FREE char *mp = NULL, *opts = NULL, *err = NULL;
- struct stat statbuf;
- int r;
-
- ABS_PATH (mountpoint, 0, return -1);
-
- mp = sysroot_path (mountpoint);
- if (!mp) {
- reply_with_perror ("malloc");
- return -1;
- }
-
- /* Check the mountpoint exists and is a directory. */
- if (stat (mp, &statbuf) == -1) {
- reply_with_perror ("%s", mountpoint);
- return -1;
- }
- if (!S_ISDIR (statbuf.st_mode)) {
- reply_with_perror ("%s: mount point is not a directory", mountpoint);
- return -1;
- }
-
- /* Add trans=virtio to the options. */
- if ((optargs_bitmask & GUESTFS_MOUNT_9P_OPTIONS_BITMASK) &&
- STRNEQ (options, "")) {
- if (asprintf (&opts, "trans=virtio,%s", options) == -1) {
- reply_with_perror ("asprintf");
- return -1;
- }
- }
- else {
- opts = strdup ("trans=virtio");
- if (opts == NULL) {
- reply_with_perror ("strdup");
- return -1;
- }
- }
-
- modprobe_9pnet_virtio ();
- r = command (NULL, &err,
- "mount", "-o", opts, "-t", "9p",
mount_tag, mp, NULL);
- if (r == -1) {
- reply_with_error ("%s on %s: %s", mount_tag, mountpoint, err);
- return -1;
- }
-
- return 0;
+ reply_with_perror ("9p support was removed in libguestfs 1.48");
+ return -1;
}
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 8884f35807..d82ddb70eb 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -6157,27 +6157,6 @@ This returns true iff the device exists and contains all zero
bytes.
Note that for large devices this can take a long time to run." };
- { defaults with
- name = "list_9p"; added = (1, 11, 12);
- style = RStringList (RPlainString, "mounttags"), [], [];
- shortdesc = "list 9p filesystems";
- longdesc = "\
-List all 9p filesystems attached to the guest. A list of
-mount tags is returned." };
-
- { defaults with
- name = "mount_9p"; added = (1, 11, 12);
- style = RErr, [String (PlainString, "mounttag"); String (PlainString,
"mountpoint")], [OString "options"];
- camel_name = "Mount9P";
- shortdesc = "mount 9p filesystem";
- longdesc = "\
-Mount the virtio-9p filesystem with the tag C<mounttag> on the
-directory C<mountpoint>.
-
-If required, C<trans=virtio> will be automatically added to the options.
-Any other options required can be passed in the optional C<options>
-parameter." };
-
{ defaults with
name = "list_dm_devices"; added = (1, 11, 15);
style = RStringList (RDevice, "devices"), [], [];
diff --git a/generator/actions_core_deprecated.ml b/generator/actions_core_deprecated.ml
index 27b358f17b..60d11bfee5 100644
--- a/generator/actions_core_deprecated.ml
+++ b/generator/actions_core_deprecated.ml
@@ -899,4 +899,21 @@ C<device> parameter must be the name of the LUKS mapping
device (ie. F</dev/mapper/mapname>) and I<not> the name
of the underlying block device." };
+ { defaults with
+ name = "list_9p"; added = (1, 11, 12);
+ style = RStringList (RPlainString, "mounttags"), [], [];
+ shortdesc = "list 9p filesystems";
+ deprecated_by = Deprecated_no_replacement;
+ longdesc = "\
+This call does nothing and returns an error." };
+
+ { defaults with
+ name = "mount_9p"; added = (1, 11, 12);
+ style = RErr, [String (PlainString, "mounttag"); String (PlainString,
"mountpoint")], [OString "options"];
+ camel_name = "Mount9P";
+ deprecated_by = Deprecated_no_replacement;
+ shortdesc = "mount 9p filesystem";
+ longdesc = "\
+This call does nothing and returns an error." };
+
]
diff --git a/tests/9p/test-9p.sh b/tests/9p/test-9p.sh
deleted file mode 100755
index 4fd5de7fda..0000000000
--- a/tests/9p/test-9p.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash -
-# libguestfs
-# Copyright (C) 2012 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Test 9p filesystems for Avi. As there is no way to add a 9p disk to
-# libguestfs, we have to fake it using 'config'.
-
-set -e
-
-$TEST_FUNCTIONS
-skip_if_skipped
-skip_unless_backend direct
-
-# The name of the virtio-9p device is different on some architectures.
-case "$(uname -m)" in
- arm*)
- virtio_9p=virtio-9p-device
- ;;
- s390*)
- virtio_9p=virtio-9p-ccw
- ;;
- *)
- virtio_9p=virtio-9p-pci
- ;;
-esac
-
-rm -f test-9p.img test-9p.out
-
-guestfish <<EOF
-# This dummy disk is not actually used, but libguestfs requires one.
-sparse test-9p.img 1M
-
-config -device '$virtio_9p,fsdev=test9p,mount_tag=test9p'
-config -fsdev 'local,id=test9p,path=${abs_srcdir}/9p,security_model=passthrough'
-
-run
-
-mount-9p test9p /
-ls / | grep 'test-9p.sh\$' > test-9p.out
-
-EOF
-
-if [ "$(cat test-9p.out)" != "test-9p.sh" ]; then
- echo "$0: unexpected output from listing 9p directory:"
- cat test-9p.out
- exit 1
-fi
-
-rm test-9p.img test-9p.out
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 707a840225..c65fc2669a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,9 +43,6 @@ check-slow:
check-valgrind:
$(MAKE) VG="@VG@" check
-TESTS += 9p/test-9p.sh
-EXTRA_DIST += 9p/test-9p.sh
-
SLOW_TESTS += bigdirs/test-big-dirs.pl
EXTRA_DIST += bigdirs/test-big-dirs.pl
--
2.35.1