[PATCH 0/7] Support Windows BitLocker (RHBZ#1808977).
by Richard W.M. Jones
These commits, along with the associated changes to common:
https://www.redhat.com/archives/libguestfs/2020-March/msg00286.html
support the transparent decryption and inspection of Windows guests
encrypted with BitLocker encryption.
To do the BitLocker decryption requires cryptsetup 2.3.0 (although
cryptsetup 2.3 is not required for existing LUKS use). It also
requires a new-ish Linux kernel, I believe 5.3+
This starts by adding new APIs cryptsetup-open and cryptsetup-close.
As well as dropping the "luks-" prefix, this allows specifying an
optional type parameter, allowing you to select BitLocker encryption.
Although also the new API does not require this parameter, and will
autodetect the correct type of decryption to apply in every known
case.
The main work is then in updating list-filesystems and ensuring that
inspection still works.
This really needs but also lacks tests. See commit message of patch
1/7 for why. I believe it's impossible for us to prove unit testing
right now, but hopefully this situation can improve in future.
Rich.
4 years, 4 months
[PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
by Sam Eiderman
The python3 bindings create PyUnicode objects from application strings
on the guest (i.e. installed rpm, deb packages).
It is documented that rpm package fields such as description should be
utf8 encoded - however in some cases they are not a valid unicode
string, on SLES11 SP4 the encoding of the description of the following
packages is latin1 and they fail to be converted to unicode using
guestfs_int_py_fromstring() (which invokes PyUnicode_FromString()):
PackageKit
aaa_base
coreutils
dejavu
desktop-data-SLED
gnome-utils
hunspell
hunspell-32bit
hunspell-tools
libblocxx6
libexif
libgphoto2
libgtksourceview-2_0-0
libmpfr1
libopensc2
libopensc2-32bit
liborc-0_4-0
libpackagekit-glib10
libpixman-1-0
libpixman-1-0-32bit
libpoppler-glib4
libpoppler5
libsensors3
libtelepathy-glib0
m4
opensc
opensc-32bit
permissions
pinentry
poppler-tools
python-gtksourceview
splashy
syslog-ng
tar
tightvnc
xorg-x11
xorg-x11-xauth
yast2-mouse
Fix this by globally changing guestfs_int_py_fromstring()
and guestfs_int_py_fromstringsize() to fallback to latin1 decoding if
utf-8 decoding fails.
Using the "strict" error handler doesn't matter in the case of latin1
and has the same effect of "replace":
https://docs.python.org/3/library/codecs.html#error-handlers
Signed-off-by: Sam Eiderman <sameid(a)google.com>
---
python/handle.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/python/handle.c b/python/handle.c
index 2fb8c18f0..fe89dc58a 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -387,7 +387,7 @@ guestfs_int_py_fromstring (const char *str)
#if PY_MAJOR_VERSION < 3
return PyString_FromString (str);
#else
- return PyUnicode_FromString (str);
+ return guestfs_int_py_fromstringsize (str, strlen (str));
#endif
}
@@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size)
#if PY_MAJOR_VERSION < 3
return PyString_FromStringAndSize (str, size);
#else
- return PyUnicode_FromStringAndSize (str, size);
+ PyObject *s = PyUnicode_FromString (str);
+ if (s == NULL) {
+ PyErr_Clear ();
+ s = PyUnicode_Decode (str, strlen(str), "latin1", "strict");
+ }
+ return s;
#endif
}
--
2.26.2.303.gf8c07b1a785-goog
4 years, 4 months
[PATCH virt-v2v] v2v: Allow temporary directory to be set on a global basis.
by Richard W.M. Jones
Previously we placed large files in g#get_cachedir () (usually
/var/tmp). However the problem is this ties the libguestfs appliance
and the virt-v2v overlay files to the same location.
When virt-v2v is run in a container, or any other situation where
local storage is limited, it's helpful to be able to put the overlay
files on an externally mounted PVC, which might be using NFS and
shared between containers. But putting the libguestfs appliance on
NFS in a shared location is certainly not recommended.
This allows the two locations to be set separately:
VIRT_V2V_TMPDIR - location of large temporary files, can use NFS
and may be shared
LIBGUESTFS_CACHEDIR - location of libguestfs appliance
Another motivation for this patch is to allow more reliable cleanup of
temporary files by an external process, as described in the updated
documentation.
---
docs/virt-v2v.pod | 21 +++++++++++++++++----
v2v/input_ova.ml | 4 ++--
v2v/input_vmx.ml | 3 +--
v2v/nbdkit.ml | 3 +--
v2v/output_glance.ml | 3 +--
v2v/output_null.ml | 5 ++---
v2v/output_rhv_upload.ml | 3 +--
v2v/parse_ova.ml | 5 ++---
v2v/python_script.ml | 3 +--
v2v/utils.ml | 8 ++++++--
v2v/utils.mli | 4 ++++
v2v/v2v.ml | 15 ++++++---------
12 files changed, 44 insertions(+), 33 deletions(-)
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index ed95fdc8e..dbfd10cad 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -1206,8 +1206,9 @@ possible.
=head3 Disk space
-Virt-v2v places potentially large temporary files in C<$TMPDIR> (which
-is F</var/tmp> if you don't set it). Using tmpfs is a bad idea.
+Virt-v2v places potentially large temporary files in
+C<$VIRT_V2V_TMPDIR> (or F</var/tmp>, see also L</ENVIRONMENT VARIBLES>
+below). Using tmpfs is a bad idea.
For each guest disk, an overlay is stored temporarily. This stores
the changes made during conversion, and is used as a cache. The
@@ -1554,10 +1555,22 @@ conversion.
=over 4
+=item C<VIRT_V2V_TMPDIR>
+
+=item C<LIBGUESTFS_CACHEDIR>
+
=item C<TMPDIR>
-Location of the temporary directory used for the potentially large
-temporary overlay file.
+Location of the temporary directory. This is used for the potentially
+large temporary overlay files. Also for miscellaneous temporary
+files. These environment variables are checked in order:
+C<VIRT_V2V_TMPDIR>, C<LIBGUESTFS_CACHEDIR>, C<TMPDIR>. If none are
+set then F</var/tmp> is used.
+
+To reliably ensure temporary files are cleaned up (for example in case
+virt-v2v crashes) you should create a randomly named directory under
+F</var/tmp>, set C<VIRT_V2V_TMPDIR> to point to this directory, then
+when virt-v2v exits remove the directory.
See the L</Disk space> section above.
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 5d3bece18..86f81e1f9 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -132,8 +132,8 @@ class input_ova ova = object
(* The spec allows the file to be gzip-compressed, in
* which case we must uncompress it into a temporary.
*)
- let temp_dir = (open_guestfs ())#get_cachedir () in
- let new_filename = Filename.temp_file ~temp_dir "ova" ".vmdk" in
+ let new_filename =
+ Filename.temp_file ~temp_dir:Utils.tmpdir "ova" ".vmdk" in
unlink_on_exit new_filename;
let cmd =
sprintf "zcat %s > %s" (quote filename) (quote new_filename) in
diff --git a/v2v/input_vmx.ml b/v2v/input_vmx.ml
index f1d143e97..5a1804182 100644
--- a/v2v/input_vmx.ml
+++ b/v2v/input_vmx.ml
@@ -389,8 +389,7 @@ and find_nics vmx =
class input_vmx input_password input_transport arg =
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "vmx." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "vmx." in
rmdir_on_exit t;
t in
object
diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml
index 65317f9b9..188647f65 100644
--- a/v2v/nbdkit.ml
+++ b/v2v/nbdkit.ml
@@ -105,8 +105,7 @@ let add_filter_if_available cmd filter =
let run_unix cmd =
(* Create a temporary directory where we place the socket and PID file. *)
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "v2vnbdkit." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "v2vnbdkit." in
(* tmpdir must be readable (but not writable) by "other" so that
* qemu can open the sockets.
*)
diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml
index 0a9e91818..fce223333 100644
--- a/v2v/output_glance.ml
+++ b/v2v/output_glance.ml
@@ -33,8 +33,7 @@ class output_glance () =
* to write to a temporary file. XXX
*)
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "glance." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "glance." in
rmdir_on_exit t;
t in
object
diff --git a/v2v/output_null.ml b/v2v/output_null.ml
index 3528da50a..5ce30d557 100644
--- a/v2v/output_null.ml
+++ b/v2v/output_null.ml
@@ -50,7 +50,7 @@ let can_use_qemu_null_co_device () =
(* We actually attempt to convert a raw file to the null-co device
* using a JSON URL.
*)
- let tmp = Filename.temp_file "v2vqemunullcotst" ".img" in
+ let tmp = Filename.temp_file ~temp_dir:tmpdir "v2vqemunullcotst" ".img" in
Unix.truncate tmp 1024;
let json = [
@@ -75,8 +75,7 @@ class output_null =
* the null-co device w/ a JSON URL.
*)
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "null." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "null." in
rmdir_on_exit t;
t in
object
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 5c6c26110..4922a2040 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -155,8 +155,7 @@ class output_rhv_upload output_alloc output_conn
rhv_options =
(* Create a temporary directory which will be deleted on exit. *)
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "rhvupload." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "rhvupload." in
rmdir_on_exit t;
t in
diff --git a/v2v/parse_ova.ml b/v2v/parse_ova.ml
index 0b939ac43..1f332a82c 100644
--- a/v2v/parse_ova.ml
+++ b/v2v/parse_ova.ml
@@ -71,8 +71,7 @@ let rec parse_ova ova =
if is_directory ova then ova, Directory
else (
let tmpdir =
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "ova." in
+ let t = Mkdtemp.temp_dir ~base_dir:tmpdir "ova." in
rmdir_on_exit t;
t in
@@ -222,7 +221,7 @@ and uncompress_head format file =
and uncompressed_type format file =
let head, headlen = uncompress_head format file in
let tmpfile, chan =
- Filename.open_temp_file "ova.file." "" in
+ Filename.open_temp_file ~temp_dir:tmpdir "ova.file." "" in
output chan head 0 headlen;
close_out chan;
let ret = detect_file_type tmpfile in
diff --git a/v2v/python_script.ml b/v2v/python_script.ml
index 33c5e9a21..2d95f4bd5 100644
--- a/v2v/python_script.ml
+++ b/v2v/python_script.ml
@@ -35,8 +35,7 @@ let create ?(name = "script.py") ?tmpdir code =
let tmpdir =
match tmpdir with
| None ->
- let base_dir = (open_guestfs ())#get_cachedir () in
- let t = Mkdtemp.temp_dir ~base_dir "v2v." in
+ let t = Mkdtemp.temp_dir ~base_dir:Utils.tmpdir "v2v." in
rmdir_on_exit t;
t
| Some dir -> dir in
diff --git a/v2v/utils.ml b/v2v/utils.ml
index ccbb9d68a..8cc24d6a2 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -24,6 +24,10 @@ open Std_utils
open Tools_utils
open Common_gettext.Gettext
+let tmpdir =
+ try Sys.getenv "VIRT_V2V_TMPDIR"
+ with Not_found -> (open_guestfs ())#get_cachedir ()
+
(* Is SELinux enabled and enforcing on the host? *)
let have_selinux =
0 = Sys.command "getenforce 2>/dev/null | grep -isq Enforcing"
@@ -112,7 +116,8 @@ let qemu_img_supports_offset_and_size () =
(* We actually attempt to create a qcow2 file with a raw backing
* file that has an offset and size.
*)
- let tmp = Filename.temp_file "v2vqemuimgtst" ".img" in
+ let tmp = Filename.temp_file ~temp_dir:tmpdir "v2vqemuimgtst" ".img" in
+ unlink_on_exit tmp;
Unix.truncate tmp 1024;
let json = [
@@ -132,7 +137,6 @@ let qemu_img_supports_offset_and_size () =
(if verbose () then "" else " 2>&1") in
debug "%s" cmd;
let r = 0 = Sys.command cmd in
- Unix.unlink tmp;
debug "qemu-img supports \"offset\" and \"size\" in json URLs: %b" r;
r
diff --git a/v2v/utils.mli b/v2v/utils.mli
index 937e2b9b8..5afe2954f 100644
--- a/v2v/utils.mli
+++ b/v2v/utils.mli
@@ -18,6 +18,10 @@
(** Utilities used in virt-v2v only. *)
+val tmpdir : string
+(** [VIRT_V2V_TMPDIR] or [/var/tmp]. Create all temporary files
+ under this directory. *)
+
val have_selinux : bool
(** True if SELinux is enabled and enforcing on the host. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 73edff2c4..6dd5fc693 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -264,8 +264,6 @@ and set_source_networks_and_bridges cmdline source =
let nics = List.map (Networks.map cmdline.network_map) source.s_nics in
{ source with s_nics = nics }
-and overlay_dir = (open_guestfs ())#get_cachedir ()
-
(* Conversion can fail or hang if there is insufficient free space in
* the temporary directory used to store overlays on the host
* (RHBZ#1316479). Although only a few hundred MB is actually
@@ -273,12 +271,12 @@ and overlay_dir = (open_guestfs ())#get_cachedir ()
* guestfs appliance which is also stored here.
*)
and check_host_free_space () =
- let free_space = StatVFS.free_space (StatVFS.statvfs overlay_dir) in
- debug "check_host_free_space: overlay_dir=%s free_space=%Ld"
- overlay_dir free_space;
+ let free_space = StatVFS.free_space (StatVFS.statvfs tmpdir) in
+ debug "check_host_free_space: tmpdir=%s free_space=%Ld"
+ tmpdir free_space;
if free_space < 1_073_741_824L then
error (f_"insufficient free space in the conversion server temporary directory %s (%s).\n\nEither free up space in that directory, or set the LIBGUESTFS_CACHEDIR environment variable to point to another directory with more than 1GB of free space.\n\nSee also the virt-v2v(1) manual, section \"Minimum free space check in the host\".")
- overlay_dir (human_size free_space)
+ tmpdir (human_size free_space)
(* Create a qcow2 v3 overlay to protect the source image(s). *)
and create_overlays source_disks =
@@ -286,7 +284,7 @@ and create_overlays source_disks =
List.mapi (
fun i ({ s_qemu_uri = qemu_uri; s_format = format } as source) ->
let overlay_file =
- Filename.temp_file ~temp_dir:overlay_dir "v2vovl" ".qcow2" in
+ Filename.temp_file ~temp_dir:tmpdir "v2vovl" ".qcow2" in
unlink_on_exit overlay_file;
(* There is a specific reason to use the newer qcow2 variant:
@@ -822,8 +820,7 @@ and actual_target_size target_file disk_stats =
and preserve_overlays overlays src_name =
List.iter (
fun ov ->
- let saved_filename =
- sprintf "%s/%s-%s.qcow2" overlay_dir src_name ov.ov_sd in
+ let saved_filename = sprintf "%s/%s-%s.qcow2" tmpdir src_name ov.ov_sd in
rename ov.ov_overlay_file saved_filename;
info (f_"Overlay saved as %s [--debug-overlays]") saved_filename
) overlays
--
2.25.0
4 years, 5 months
[PATCH v4 00/34] Configurable policy for handling deprecated interfaces
by Markus Armbruster
This series extends QMP introspection to cover deprecation.
Additionally, new option -compat lets you configure what to do when
deprecated interfaces get used. This is intended for testing users of
the management interfaces. It is experimental.
-compat deprecated-input=<in-policy> configures what to do when
deprecated input is received. Available policies:
* accept: Accept deprecated commands and arguments (default)
* reject: Reject them
* crash: Crash
-compat deprecated-output=<out-policy> configures what to do when
deprecated output is sent. Available output policies:
* accept: Emit deprecated command results and events (default)
* hide: Suppress them
For now, -compat covers only deprecated syntactic aspects of QMP. We
may want to extend it to cover semantic aspects, CLI, and experimental
features.
PATCH 01-04: Documentation fixes
PATCH 05-10: Test improvements
PATCH 11-24: Add feature flags to remaining user-defined types and to
struct members
PATCH 25-26: New special feature 'deprecated', visible in
introspection
PATCH 27-34: New -compat to set policy for handling stuff marked with
feature 'deprecated'
v4:
PATCH 05+07: Temporary memory leak plugged [Marc-André]
PATCH 23: Rewritten [Marc-André]
PATCH 24: Comment typo [Marc-André]
PATCH 30: Memory leaks plugged
v3:
* Rebased, non-trivial conflicts in PATCH 01+26+27+34 due to RST
conversion and code motion
* PATCH 28-29: Old PATCH 28 split up to ease review
* PATCH 30-31: New
* PATCH 32-33: Old PATCH 29 split up to ease review
Comparison to RFC (24 Oct 2019):
* Cover arguments and results in addition to commands and events
* Half-baked "[RFC PATCH 18/19] qapi: Include a warning in the
response to a deprecated command" dropped
See also last item of
Subject: Minutes of KVM Forum BoF on deprecating stuff
Date: Fri, 26 Oct 2018 16:03:51 +0200
Message-ID: <87mur0ls8o.fsf(a)dusky.pond.sub.org>
https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html
Cc: Lukáš Doktor <ldoktor(a)redhat.com>
Cc: libguestfs(a)redhat.com
Cc: libvir-list(a)redhat.com
Cc: Daniel P. Berrange <berrange(a)redhat.com>
Cc: Peter Krempa <pkrempa(a)redhat.com>
Cc: Kevin Wolf <kwolf(a)redhat.com>
Markus Armbruster (34):
qemu-doc: Belatedly document QMP command arg & result deprecation
qapi: Belatedly update doc comment for @wait deprecation
docs/devel/qapi-code-gen: Clarify allow-oob introspection
docs/devel/qapi-code-gen: Document 'features' introspection
tests/test-qmp-cmds: Factor out qmp_dispatch() test helpers
tests/test-qmp-cmds: Check responses more thoroughly
tests/test-qmp-cmds: Simplify test data setup
tests/test-qmp-event: Simplify test data setup
tests/test-qmp-event: Use qobject_is_equal()
tests/test-qmp-event: Check event is actually emitted
qapi/schema: Clean up around QAPISchemaEntity.connect_doc()
qapi: Add feature flags to remaining definitions
qapi: Consistently put @features parameter right after @ifcond
qapi/introspect: Rename *qlit* to reduce confusion
qapi/introspect: Factor out _make_tree()
qapi/schema: Change _make_features() to a take feature list
qapi/schema: Reorder classes so related ones are together
qapi/schema: Rename QAPISchemaObjectType{Variant,Variants}
qapi/schema: Call QAPIDoc.connect_member() in just one place
qapi: Add feature flags to struct members
qapi: Inline do_qmp_dispatch() into qmp_dispatch()
qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP
qapi: Simplify how qmp_dispatch() gets the request ID
qapi: Replace qmp_dispatch()'s TODO comment by an explanation
qapi: New special feature flag "deprecated"
qapi: Mark deprecated QMP parts with feature 'deprecated'
qemu-options: New -compat to set policy for deprecated interfaces
qapi: Implement deprecated-output=hide for QMP command results
qapi: Implement deprecated-output=hide for QMP events
qapi: Implement deprecated-output=hide for QMP event data
qapi: Implement deprecated-output=hide for QMP introspection
qapi: Implement deprecated-input=reject for QMP commands
qapi: Implement deprecated-input=reject for QMP command arguments
qapi: New -compat deprecated-input=crash
docs/devel/qapi-code-gen.txt | 79 ++-
docs/system/deprecated.rst | 48 +-
tests/qapi-schema/doc-good.texi | 32 ++
qapi/block-core.json | 48 +-
qapi/block.json | 30 +-
qapi/char.json | 1 +
qapi/compat.json | 52 ++
qapi/control.json | 11 +-
qapi/introspect.json | 28 +-
qapi/machine.json | 34 +-
qapi/migration.json | 36 +-
qapi/misc.json | 13 +-
qapi/qapi-schema.json | 1 +
include/qapi/compat-policy.h | 20 +
include/qapi/qmp/dispatch.h | 1 +
include/qapi/qobject-input-visitor.h | 9 +
include/qapi/qobject-output-visitor.h | 9 +
include/qapi/visitor-impl.h | 3 +
include/qapi/visitor.h | 9 +
monitor/monitor-internal.h | 3 -
monitor/misc.c | 2 -
monitor/qmp-cmds-control.c | 102 +++-
qapi/qapi-visit-core.c | 9 +
qapi/qmp-dispatch.c | 149 +++---
qapi/qobject-input-visitor.c | 29 ++
qapi/qobject-output-visitor.c | 20 +
qemu-storage-daemon.c | 2 -
softmmu/vl.c | 17 +
tests/test-qmp-cmds.c | 249 +++++----
tests/test-qmp-event.c | 203 +++-----
qapi/Makefile.objs | 8 +-
qapi/trace-events | 1 +
qemu-options.hx | 22 +
scripts/qapi/commands.py | 20 +-
scripts/qapi/doc.py | 16 +-
scripts/qapi/events.py | 24 +-
scripts/qapi/expr.py | 14 +-
scripts/qapi/introspect.py | 104 ++--
scripts/qapi/schema.py | 488 ++++++++++--------
scripts/qapi/types.py | 8 +-
scripts/qapi/visit.py | 28 +-
tests/Makefile.include | 1 +
tests/qapi-schema/alternate-base.err | 2 +-
tests/qapi-schema/doc-good.json | 22 +-
tests/qapi-schema/doc-good.out | 18 +
.../qapi-schema/features-deprecated-type.err | 2 +
.../qapi-schema/features-deprecated-type.json | 3 +
.../qapi-schema/features-deprecated-type.out | 0
tests/qapi-schema/qapi-schema-test.json | 51 +-
tests/qapi-schema/qapi-schema-test.out | 48 +-
tests/qapi-schema/test-qapi.py | 26 +-
51 files changed, 1393 insertions(+), 762 deletions(-)
create mode 100644 qapi/compat.json
create mode 100644 include/qapi/compat-policy.h
create mode 100644 tests/qapi-schema/features-deprecated-type.err
create mode 100644 tests/qapi-schema/features-deprecated-type.json
create mode 100644 tests/qapi-schema/features-deprecated-type.out
--
2.21.1
4 years, 6 months
Anything for nbdkit 1.20? / ddrescue filter latest version?
by Richard W.M. Jones
Eric: Even though it's only been about 2 months, we have a very good
feature set for nbdkit 1.20. Is there anything you'd like to get in
or any patches I have missed?
Francois: you mentioned the ddrescue filter yesterday. While I don't
want to put in a new filter right before we do a release (new features
need to sit around in development so we can uncover bugs), if you do
have updated patches we could still review them.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
4 years, 6 months
golang: panic: runtime error: cgo argument has Go pointer to Go pointer
by yuankangjian
Hello,
when i use libguestfs to ceph rbd by golang, but there has panic:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
guestfs.(*Guestfs).Add_drive.func11(0xc000010028, 0xcda6a0, 0xc0000d6000, 0xc000090280)
/opt/gopath/src/guestfs/guestfs.go:1440 +0xc2
guestfs.(*Guestfs).Add_drive(0xc000010028, 0x7ffd4b5d67ff, 0xd, 0xc00008d9d8, 0x0)
/opt/gopath/src/guestfs/guestfs.go:1440 +0x1b2
main.OpenImage(0x7ffd4b5d67ff, 0xd, 0x0, 0x0, 0x42110b, 0x7c87e0, 0x4f41e0)
/opt/gopath/src/disk/disk.go:34 +0x371
main.resizeext4(0x7ffd4b5d67ff, 0xd, 0x0, 0x0)
/opt/gopath/src/disk/disk.go:677 +0x60
main.main()
/opt/gopath/src/disk/disk.go:970 +0x5e5
i found struct in guestfs.h
struct guestfs_add_drive_opts_argv {
...
char *const *server;
...
}
so i make a daemon to test. has the same error. how could i to use libguestfs to connect ceph rbd use golang interface.
package main
/*
#include <stdio.h>
#include <string.h>
struct t_server {
const char *protocol;
char *const *addr;
};
void show(struct t_server *optargs) {
if (optargs->protocol == NULL){
printf("protocol is null \n");
}
printf("proto is %s\n", optargs->protocol);
int num = strlen(*optargs->addr)-1;
int i = 0;
for(i=0;i<num;i++){
printf("%s\n",optargs->addr[i]);
}
}
*/
import "C"
import (
"unsafe"
)
func main(){
c_optargs := C.struct_t_server{}
c_optargs.protocol = C.CString("test")
serverlist := []string{"aaa", "bbb", "ccc"}
var buf []*C.char
for i, _ := range serverlist {
buf = append(buf, (*C.char)(unsafe.Pointer(C.CString(serverlist[i]))))
}
buf = append(buf, (*C.char)(unsafe.Pointer(nil)))
c_optargs.addr = &buf[0]
C.show(&c_optargs)
}
4 years, 6 months
[PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
by Richard W.M. Jones
On Haiku tests/test-socket-activation failed with:
nbdkit: locks.c:96:lock_request: conn != NULL
called from server/sockets.c: accept_connection
in the fallback path which does:
lock_request ();
thread_data->sock = set_cloexec (accept (listen_sock, NULL, NULL));
unlock_request ()
Because there is no current connection in this thread this code fails.
However it should be possible to call lock_request without a
connection, provided that
thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS (which it is
when the fallback path is engaged on Haiku). There was a regression
caused when I modified to code to use an implicit TLS connection.
Fixes commit 91023f269d4cea56f573a1aa0d880b12052f6e1e.
---
server/locks.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/locks.c b/server/locks.c
index 5d54d311..9269c75e 100644
--- a/server/locks.c
+++ b/server/locks.c
@@ -93,7 +93,7 @@ unlock_connection (void)
void
lock_request (void)
{
- GET_CONN;
+ struct connection *conn = threadlocal_get_conn ();
if (thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS &&
pthread_mutex_lock (&all_requests_lock))
@@ -110,7 +110,7 @@ lock_request (void)
void
unlock_request ()
{
- GET_CONN;
+ struct connection *conn = threadlocal_get_conn ();
if (pthread_rwlock_unlock (&unload_prevention_lock))
abort ();
--
2.25.0
4 years, 7 months
[PATCH nbdkit] freebsd, openbsd: Add an extern decl for environ.
by Richard W.M. Jones
---
configure.ac | 24 ++++++++++++++++++++++++
plugins/sh/call.c | 4 ++++
2 files changed, 28 insertions(+)
diff --git a/configure.ac b/configure.ac
index cdddae73..9b925539 100644
--- a/configure.ac
+++ b/configure.ac
@@ -266,6 +266,30 @@ test (int a)
]
)
+dnl 'environ' is not always declared in public header files:
+dnl Linux => <unistd.h> Haiku => <stdlib.h>
+dnl FreeBSD & OpenBSD => not declared
+dnl On platforms where it's not declared we must add an extern decl.
+AC_MSG_CHECKING([if environ is declared in header files])
+AC_COMPILE_IFELSE([
+AC_LANG_SOURCE([[
+#include <stdlib.h>
+#include <unistd.h>
+static int
+test (void)
+{
+ const char **env = environ;
+ return env ? 1 : 0; // this just forces env to be used
+}
+]])
+ ],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_ENVIRON_DECL],[1],[environ is declared in headers])
+ ],[
+ AC_MSG_RESULT([no])
+ ]
+)
+
dnl Check for other headers, all optional.
AC_CHECK_HEADERS([\
alloca.h \
diff --git a/plugins/sh/call.c b/plugins/sh/call.c
index 4ffacfcc..91e69e9a 100644
--- a/plugins/sh/call.c
+++ b/plugins/sh/call.c
@@ -53,6 +53,10 @@
#include "call.h"
+#ifndef HAVE_ENVIRON_DECL
+extern char **environ;
+#endif
+
/* Temporary directory for scripts to use. */
char tmpdir[] = "/tmp/nbdkitXXXXXX";
--
2.25.0
4 years, 7 months
[PATCH nbdkit] server: Fix parameters of lock_request, unlock_request
by Richard W.M. Jones
Patch itself is not controversial.
However I do wonder if we want to change all these constructs so that
instead of using #ifdef we use something like:
if (HAVE_PIPE2) {
// normal path
}
else {
// fallback
}
(It wouldn't actually work as written above because HAVE_PIPE2 is not
always defined, but you get the idea.)
This would allow us to test that the fallback paths still compile.
Rich.
4 years, 7 months