[PATCH] file: Normalize errno value for ENODEV
by Nir Soffer
Fix issues Eric found in the original patch:
https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html
- When handling ENODEV, the caller is expecting ENOTSUPP to trigger
fallback.
- ENODEV should be ignored in file_trim.
Tested only on Fedora 28.
---
plugins/file/file.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/plugins/file/file.c b/plugins/file/file.c
index a7c07fb..4210adb 100644
--- a/plugins/file/file.c
+++ b/plugins/file/file.c
@@ -50,6 +50,21 @@
static char *filename = NULL;
+#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE)
+static int
+do_fallocate(int fd, int mode, off_t offset, off_t len)
+{
+ int r = -1;
+ r = fallocate (fd, mode, offset, len);
+ /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails
+ with EOPNOTSUPP in this case. Normlize errno to simplify callers. */
+ if (r == -1 && errno == ENODEV) {
+ errno = EOPNOTSUPP;
+ }
+ return r;
+}
+#endif
+
static void
file_unload (void)
{
@@ -241,9 +256,9 @@ file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
#ifdef FALLOC_FL_PUNCH_HOLE
if (may_trim) {
- r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
- offset, count);
- if (r == -1 && errno != EOPNOTSUPP && errno != ENODEV) {
+ r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+ offset, count);
+ if (r == -1 && errno != EOPNOTSUPP) {
nbdkit_error ("zero: %m");
}
/* PUNCH_HOLE is older; if it is not supported, it is likely that
@@ -253,8 +268,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
#endif
#ifdef FALLOC_FL_ZERO_RANGE
- r = fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);
- if (r == -1 && errno != EOPNOTSUPP && errno != ENODEV) {
+ r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);
+ if (r == -1 && errno != EOPNOTSUPP) {
nbdkit_error ("zero: %m");
}
#else
@@ -288,11 +303,11 @@ file_trim (void *handle, uint32_t count, uint64_t offset)
struct handle *h = handle;
/* Trim is advisory; we don't care if it fails for anything other
- * than EIO, EPERM, or ENODEV (kernel 3.10) */
- r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
- offset, count);
+ * than EIO or EPERM. */
+ r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+ offset, count);
if (r < 0) {
- if (errno != EPERM && errno != EIO && errno != ENODEV) {
+ if (errno != EPERM && errno != EIO) {
nbdkit_debug ("ignoring failed fallocate during trim: %m");
r = 0;
}
--
2.17.1
6 years, 3 months
Error building nbdkit on RHEL 7.5 - possibly undefined macro: PKG_CHECK_VAR
by Nir Soffer
I'm trying to build upstream source on RHEL 7.5 and get this error:
# autoreconf -i
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:190: error: possibly undefined macro: PKG_CHECK_VAR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
How to fix this? I hope I can avoid reading autoconf documentation :-)
Nir
6 years, 4 months
[PATCH] file: Fix zero/trim with block device
by Nir Soffer
When using block device on RHEL 7.5, file plugin fails to zero with this
error (copied from strace):
[pid 39551] fallocate(8, FALLOC_FL_ZERO_RANGE, 1536, 64000) = -1 ENODEV (No such device)
This is expected error according to the manual:
ENODEV fd does not refer to a regular file or a directory. (If fd is a
pipe or FIFO, a different error results.)
Treat this error as EOPNOSUPP.
Tested only on Fedora 28; I don't know how to build nbdkit on RHEL, but
the change is pretty trivial.
---
plugins/file/file.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins/file/file.c b/plugins/file/file.c
index b6e33de..a7c07fb 100644
--- a/plugins/file/file.c
+++ b/plugins/file/file.c
@@ -243,7 +243,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
if (may_trim) {
r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
offset, count);
- if (r == -1 && errno != EOPNOTSUPP) {
+ if (r == -1 && errno != EOPNOTSUPP && errno != ENODEV) {
nbdkit_error ("zero: %m");
}
/* PUNCH_HOLE is older; if it is not supported, it is likely that
@@ -254,7 +254,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
#ifdef FALLOC_FL_ZERO_RANGE
r = fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);
- if (r == -1 && errno != EOPNOTSUPP) {
+ if (r == -1 && errno != EOPNOTSUPP && errno != ENODEV) {
nbdkit_error ("zero: %m");
}
#else
@@ -288,11 +288,11 @@ file_trim (void *handle, uint32_t count, uint64_t offset)
struct handle *h = handle;
/* Trim is advisory; we don't care if it fails for anything other
- * than EIO or EPERM. */
+ * than EIO, EPERM, or ENODEV (kernel 3.10) */
r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
offset, count);
if (r < 0) {
- if (errno != EPERM && errno != EIO) {
+ if (errno != EPERM && errno != EIO && errno != ENODEV) {
nbdkit_debug ("ignoring failed fallocate during trim: %m");
r = 0;
}
--
2.17.1
6 years, 4 months
Preparatory work on virt-v2v -o openstack mode
by Richard W.M. Jones
(Apologies if I missed anyone off the To: line. Please add anyone
else who is interested, but keep the libguestfs public mailing list)
I did some preparatory work on adding the new ‘virt-v2v -o openstack’
output mode. I've put it in a private (non-FFwd) branch here:
https://github.com/rwmjones/libguestfs/tree/openstack
Most of the work was refactoring virt-v2v so that we have all of the
metadata available at the point where we create the disks. For
Openstack this is expected to be important because (we believe) we
have to set properties on the Cinder volumes at creation time and
won't be able to modify those properties later. All of this work is
upstream in libguestfs >= 1.39.8.
The second part was adding the machinery for the new output mode.
This is the extra commit that you see in the branch above. Note this
commit does not actually do anything useful so far. The important
file to look at is v2v/output_openstack.ml.
Some other random notes:
- Before you try to build from source, read this page carefully:
http://libguestfs.org/guestfs-building.1.html
- Upstream in virt-v2v we have settled on using Python 3 only. So all
code submitted should be written in Python 3, you will have to
install python3-*client, etc.
- For RHV, in RHEL 7 we added a downstream patch which converts the
code from Python 3 to Python 2. Of course this will not be needed
in other Linux distros.
- You must supply a Keystone auth URL using ‘-oc’ (perhaps we will
allow this to be overridden by OS_* environment variables).
- How will we select "where" the guest is going to go? eg. What
region, what Cinder storage pool, etc. (And other things that may
be relevant which I don't even know to ask).
- Unclear on how auth will work, so I just assumed username/password
for now.
- I am on holiday until Wednesday 1st.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
6 years, 4 months
[PATCH] daemon: inspect: ignore fstab devs that cannot be resolved (RHBZ#1608131)
by Pino Toscano
If the /etc/fstab of a guest contains devices specified with UUID or
LABEL, then the new OCaml inspection code will report the findfs failure
as general failure of the inspection. OTOH, the old C inspection code
simply ignored all the devices that cannot be resolved.
Hence, restore the old behaviour by ignoring unresolvable devices.
---
daemon/inspect_fs_unix_fstab.ml | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/daemon/inspect_fs_unix_fstab.ml b/daemon/inspect_fs_unix_fstab.ml
index edb797e3f..170440d2c 100644
--- a/daemon/inspect_fs_unix_fstab.ml
+++ b/daemon/inspect_fs_unix_fstab.ml
@@ -115,12 +115,20 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
if String.is_prefix spec "UUID=" then (
let uuid = String.sub spec 5 (String.length spec - 5) in
let uuid = shell_unquote uuid in
- Mountable.of_device (Findfs.findfs_uuid uuid)
+ (* Just ignore the device if the UUID cannot be resolved. *)
+ try
+ Mountable.of_device (Findfs.findfs_uuid uuid)
+ with
+ Failure _ -> return None
)
else if String.is_prefix spec "LABEL=" then (
let label = String.sub spec 6 (String.length spec - 6) in
let label = shell_unquote label in
- Mountable.of_device (Findfs.findfs_label label)
+ (* Just ignore the device if the label cannot be resolved. *)
+ try
+ Mountable.of_device (Findfs.findfs_label label)
+ with
+ Failure _ -> return None
)
(* Resolve /dev/root to the current device.
* Do the same for the / partition of the *BSD
--
2.17.1
6 years, 4 months
[PATCH] v2v: rhv plugin - case-sensitive search queries
by Daniel Erez
Changed both search queries to case-sensitive (to ensure an exact match).
---
v2v/rhv-upload-plugin.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index c6ba1962f..d787c9598 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -71,7 +71,7 @@ def find_host(connection):
storage_name = params['output_storage']
data_centers = system_service.data_centers_service().list(
search='storage.name=%s' % storage_name,
- case_sensitive=False,
+ case_sensitive=True,
)
if len(data_centers) == 0:
# The storage domain is not attached to a datacenter
@@ -84,7 +84,7 @@ def find_host(connection):
hosts_service = system_service.hosts_service()
hosts = hosts_service.list(
search="hw_id=%s and datacenter=%s and status=Up" % (vdsm_id, datacenter.name),
- case_sensitive=False,
+ case_sensitive=True,
)
if len(hosts) == 0:
# This oVirt host is not registered with engine.
--
2.17.1
6 years, 4 months
[PATCH] v2v: rhv plugin - fix DC search string
by Daniel Erez
Search for DC by 'storage.name=' to make it explicit.
I.e. "storage=" uses regex, so similar names can be
found in the search query. For example, searching for
a domain named FCSD, will find FCSD1 as well.
---
v2v/rhv-upload-plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index c72f5e181..c6ba1962f 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -70,7 +70,7 @@ def find_host(connection):
system_service = connection.system_service()
storage_name = params['output_storage']
data_centers = system_service.data_centers_service().list(
- search='storage=%s' % storage_name,
+ search='storage.name=%s' % storage_name,
case_sensitive=False,
)
if len(data_centers) == 0:
--
2.17.1
6 years, 4 months
Is there any plan to support SPDK disks?
by Bob Chen
Considering that the technic of SPDK + QEMU is making progress toward
maturity.
Personally I'd like to do the integration work. Not sure somebody would
mind to give me some clue on that? Because I'm not familiar with libguestfs
code structures.
Thanks,
Bob
6 years, 4 months