[libvirt] [PATCH 00/18] qemu: virtio-{non-}transitional support
by Cole Robinson
This series adds support for virtio-transitional and
virtio-non-transitional qemu devices.
qemu patches, queued for qemu 4.0.0:
https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html
Previous libvirt discussion around this:
https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html
Previous incomplete RFC here:
https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html
Long story short we need to expose these options so apps have a
usable way to support rhel6 + virtio + q35. This series exposes
the new devices as model= values. This required adding new
model= attributes for several devices.
Here's the breakdown. 'standard names' here means the model names
virtio, virtio-transitional, and virtio-non-transitional
* Simply extended:
virtio-rng: extend existing <rng model=X> to handle standard names
vhost-vsock: extend existing <vsock model=X> to handle standard names
virtio-memballoon: extend existings <memballoon model=X> to handle
standard names
virtio-net: extend existing qemu <model type=X> handling to
support standard names
* Extended with caveats:
virtio-serial: extend <controller type='virtio-serial'> to handle
existing model=X attribute, with standard names
virtio-scsi: extend <controller type='scsi' model=X> to handle the
additional names virtio-transitional and virtio-non-transitional.
model= already supports virtio-scsi here which is a departure from
just model='virtio' which most others use, but I chose to not
extend that pattern and stick with the names the other devices
are using
vhost-scsi: extend <hostdev model=X> handling for the protocol=vhost
case, to accept standard names. I stuck with standard names over
using vhost-transitional or similar, for consistency with other
devices.
* New XML elements
virtio-blk: add new <disk model=X/> attribute with standard names
virtio-fs: add new <filesystem model=X> attribute with standard names
virtio-input-host: add new <input model=X> attribute with
standard names
At the end is an extension to domaincapabilities to report the
disk bus model values. Until domaincapabilities is fully fleshed
out with support for all the above devices, apps can use that
disk model check to assume transitional devices are available
for all of the above.
Cole Robinson (18):
tests: Add capabilities data for QEMU 4.0.0 x86_64
conf: Add <disk model='virtio-{non-}transitional'/>
qemu: Support disk model=virtio-{non-}transitional
conf: Add virDomainNetHasVirtioModel
qemu: Support interface model=virtio-{non-}transitional
conf: Add <hostdev model='virtio-{non-}transitional'/>
qemu: Support hostdev model=virtio-{non-}transitional
qemu: Support rng model=virtio-{non-}transitional
conf: Add <filesystem model='virtio-{non-}transitional'/>
qemu: Support filesystem model=virtio-{non-}transitional
qemu: Move memballoon validation out of command.c
qemu: Support memballoon model=virtio-{non-}transitional
qemu: Support vsock model=virtio-{non-}transitional
conf: Add <input model='virtio-{non-}transitional'/>
qemu: Support input model=virtio-{non-}transitional
qemu: Support scsi controller model=virtio-{non-}transitional
qemu: Support virtio-serial controller model=virtio-{non-}transitional
qemu: domcaps: Report disk <enum name="model">
docs/formatdomain.html.in | 39 +-
docs/schemas/domaincommon.rng | 60 +-
src/conf/domain_capabilities.c | 1 +
src/conf/domain_capabilities.h | 1 +
src/conf/domain_conf.c | 216 +-
src/conf/domain_conf.h | 68 +-
src/libvirt_private.syms | 5 +
src/libxl/libxl_conf.c | 2 +
src/qemu/qemu_capabilities.c | 55 +
src/qemu/qemu_capabilities.h | 28 +
src/qemu/qemu_command.c | 219 +-
src/qemu/qemu_domain.c | 47 +-
src/qemu/qemu_domain_address.c | 69 +-
src/qemu/qemu_driver.c | 9 +-
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_interface.c | 8 +-
src/qemu/qemu_process.c | 3 +-
src/security/virt-aa-helper.c | 2 +-
src/vbox/vbox_common.c | 2 +
src/vmx/vmx.c | 4 +-
.../bhyve_basic.x86_64.xml | 1 +
.../bhyve_fbuf.x86_64.xml | 1 +
.../bhyve_uefi.x86_64.xml | 1 +
tests/domaincapsschemadata/full.xml | 6 +
.../domaincapsschemadata/libxl-xenfv-usb.xml | 1 +
.../domaincapsschemadata/libxl-xenpv-usb.xml | 1 +
.../qemu_1.7.0.x86_64.xml | 1 +
.../qemu_2.12.0-virt.aarch64.xml | 1 +
.../qemu_2.12.0.ppc64.xml | 1 +
.../qemu_2.12.0.s390x.xml | 1 +
.../qemu_2.12.0.x86_64.xml | 1 +
.../qemu_2.6.0-virt.aarch64.xml | 1 +
.../qemu_2.6.0.aarch64.xml | 1 +
.../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 +
.../qemu_2.6.0.x86_64.xml | 1 +
.../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 +
.../qemu_2.8.0-tcg.x86_64.xml | 1 +
.../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 +
.../qemu_2.8.0.x86_64.xml | 1 +
.../qemu_2.9.0-q35.x86_64.xml | 1 +
.../qemu_2.9.0-tcg.x86_64.xml | 1 +
.../qemu_2.9.0.x86_64.xml | 1 +
.../domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 +
.../qemu_4.0.0.x86_64.xml | 153 +
tests/domaincapstest.c | 4 +
.../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++
.../caps_4.0.0.x86_64.xml | 1404 +
tests/qemucapabilitiestest.c | 1 +
.../virtio-non-transitional.x86_64-3.1.0.args | 63 +
...virtio-non-transitional.x86_64-latest.args | 62 +
.../virtio-non-transitional.xml | 40 +
.../virtio-transitional.x86_64-3.1.0.args | 50 +
.../virtio-transitional.x86_64-latest.args | 52 +
.../qemuxml2argvdata/virtio-transitional.xml | 40 +
tests/qemuxml2argvmock.c | 2 +-
tests/qemuxml2argvtest.c | 6 +
.../virtio-non-transitional.xml | 121 +
.../virtio-transitional.xml | 80 +
tests/qemuxml2xmltest.c | 17 +
59 files changed, 26031 insertions(+), 112 deletions(-)
create mode 100644 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml
create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies
create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args
create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.xml
create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args
create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/virtio-transitional.xml
create mode 100644 tests/qemuxml2xmloutdata/virtio-non-transitional.xml
create mode 100644 tests/qemuxml2xmloutdata/virtio-transitional.xml
--
2.20.1
5 years, 9 months
[libvirt] exposing host-passthrough in virt-manager ui? (was: Re: [virt-tools-list] small suggestion)
by Cole Robinson
On 2/6/19 10:57 AM, Pavel Hrdina wrote:
> On Wed, Feb 06, 2019 at 10:20:38AM -0500, Cole Robinson wrote:
>> On 2/5/19 6:19 PM, Hetz Ben Hamo wrote:
>>> Is it possible to add in the virt-manager the "host-passthrough" to the
>>> CPU models please?
>>>
>>
>> You can type 'host-passthrough' into the field and it will work. The reason
>> we don't advertise it is because it's considered to have some mild
>> supportability issues with libvirt. For the vast majority of use cases
>> though it's completely fine
>
> Maybe we can reconsider this decision, the only thing that would not
> work is live migration to destination with different CPU and we can
> have a warning/info about it in the UI.
>
> Possibly we could allow to set 'host-passthrough' as the default guest
> CPU in virt-manager config.
>
Nowadays with host-model being much smarter, is there much functional
difference between host-model and host-passthrough? I don't really know
the answer.
> Most workstation/desktop users of virt-manager probably doesn't care
> about live migration and it would copy the host CPU as closely as
> possible. Since we allow to manually type in 'host-passthrough' I
> personally don't see any reason why it cannot be selectable.
>
The problem I see is that host-passthrough sets the libvirt 'taint' flag
on the VM. While it doesn't have any real impact on end users generally
I took that to mean 'you are doing something that is unsupported'.
I don't personally don't have strong feelings against it but I've just
followed the advice I've been given here. Things have changed quite a
bit in the cpu config space in the past few years so maybe things are
different. changing subject and ccing libvir-list for wider audience
Thanks,
Cole
5 years, 9 months
[libvirt] [PATCH] dosc: schema: fix usb source address device attribute format
by Nikolay Shirokovskiy
Device attribute does not have dotted "portAddr" format. Instead it
has single number format described but "usbAddr" which corresponds
to device parsing code in virDomainHostdevSubsysUSBDefParseXML.
Looks like [1] mistakenly changed device format for hostdev devices.
And [2] copy-n-paste this for hostdev network interfaces.
[1] 31710a53 Modify USB port to be defined as a port path
[2] 3b1c191f conf: parse/format type='hostdev' network interfaces
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
docs/schemas/domaincommon.rng | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index aa50eac..8c8d87e 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2765,7 +2765,7 @@
<ref name="usbAddr"/>
</attribute>
<attribute name="device">
- <ref name="usbPort"/>
+ <ref name="usbAddr"/>
</attribute>
</group>
</choice>
@@ -4709,7 +4709,7 @@
<ref name="usbAddr"/>
</attribute>
<attribute name="device">
- <ref name="usbPort"/>
+ <ref name="usbAddr"/>
</attribute>
</element>
</define>
--
1.8.3.1
5 years, 9 months
[libvirt] running Libvirt from source code, IPC_LOCK and VFIO
by Daniel Henrique Barboza
Hi,
I'm facing a strange behavior when running Libvirt from source code,
latest upstream, on an Ubuntu 18.04.1 LTS Power 9 server. My QEMU
guest - which is using VFIO and GPU passthrough - breaks on boot when
trying to allocate a DMA window inside KVM.
Debugging the code, I've found out that the problem is related to the
process
not having CAP_IPC_LOCK - at least from the host kernel perspective.
This is strange because:
- the same VM running directly from QEMU command line works
- the same VM running in the system Libvirt (v4.0.0, Ubuntu version)
also works
What am I missing? My understanding on Linux process is that a process
running as root should inherit the same capabilities of the user, which
includes
CAP_IPC_LOCK. Running Libvirt from source code should grant ipc_lock
to it ... right?
Any help is appreciated. I can provide more details (VM XML for example)
if necessary.
Thanks!
5 years, 9 months
[libvirt] [jenkins-ci PATCH] Add support for cross compiling libvirt via Debian
by Daniel P. Berrangé
Debian's filesystem layout has a nice advantage over Fedora which is
that it can install non-native RPMs in the main root filesystem. It is
thus possible to prepare an x86_64 filesystem containing -dev packages
for a foreign architecture, along with a GCC cross compiler.
QEMU has used this technique to facilitate developer build testing of
non-x86 architectures, since few people have access to physical
hardware for most of these architectures. For the same reason it would
be helpful to libvirt developers.
This docker file allows creation of containers buildenv-cross-$ARCH
for arm64, armel, armhf, mips, mipsel, mips64el, ppc64el, s390x, based
off Debian 9, in which libvirt can be cross-compiled. Debian can support
further architectures, but only by using the unstable 'sid' repos. This
does not enable use of 'sid' but it could be added fairly easily at a
later date if desired. Most of the other architectures are fairly
old & obscure, the main interesting exception being riscv64.
If qemu-user emulators are registered with the kernel binfmt, then it
is theoretically possible to run "make check" tool, though this has not
been tested.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
.gitignore | 1 +
cross-build/arch-config.csv | 8 +++
cross-build/buildenv-cross.docker.in | 96 ++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
create mode 100644 cross-build/arch-config.csv
create mode 100644 cross-build/buildenv-cross.docker.in
diff --git a/.gitignore b/.gitignore
index b25c15b..4884352 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*~
+cross-build/*docker
diff --git a/cross-build/arch-config.csv b/cross-build/arch-config.csv
new file mode 100644
index 0000000..36fcb5f
--- /dev/null
+++ b/cross-build/arch-config.csv
@@ -0,0 +1,8 @@
+arm64,crossbuild-essential-arm64,aarch64-linux-gnu
+armel,crossbuild-essential-armel,arm-linux-gnueabi
+armhf,crossbuild-essential-armhf,arm-linux-gnueabihf
+mips64el,gcc-mips64el-linux-gnuabi64,mips64el-linux-gnuabi64
+mips,gcc-mips-linux-gnu,mips-linux-gnu
+mipsel,gcc-mipsel-linux-gnu,mipsel-linux-gnu
+ppc64el,crossbuild-essential-ppc64el,powerpc64le-linux-gnu
+s390x,gcc-multilib-s390x-linux-gnu,s390x-linux-gnu
diff --git a/cross-build/buildenv-cross.docker.in b/cross-build/buildenv-cross.docker.in
new file mode 100644
index 0000000..97a9e69
--- /dev/null
+++ b/cross-build/buildenv-cross.docker.in
@@ -0,0 +1,96 @@
+#
+# ::ARCH:: cross-compiler target
+#
+FROM debian:stretch-slim
+
+# Grab the updated list of packages
+RUN apt update && apt dist-upgrade -yy
+
+# First some common native binaries. Any program that the
+# build will execute needs to have a native binary package
+# installed. We don't want to rely on qemu-user emulation
+# for executing non-native binaries as that is slow & flaky
+RUN DEBIAN_FRONTEND=noninteractive \
+ apt-get install -y --no-install-recommends \
+ git \
+ build-essential \
+ ca-certificates \
+ libtool\
+ autoconf \
+ automake \
+ python3 \
+ xsltproc \
+ parted \
+ radvd \
+ qemu-system-common \
+ dwarves \
+ libxml2-utils \
+ dnsmasq-base \
+ openssh-client \
+ netcat-openbsd \
+ ebtables \
+ iptables \
+ sheepdog \
+ qemu-utils \
+ qemu-system-x86 \
+ pkg-config
+
+
+# Add the ::ARCH:: architecture
+RUN dpkg --add-architecture ::ARCH::
+
+
+# Grab the freshly updated list of packages
+RUN apt update
+
+
+# Pull in the native package for the cross-compiler
+RUN DEBIAN_FRONTEND=noninteractive \
+ apt-get install -y --no-install-recommends \
+ ::COMPILER::
+
+# Finally pull in the foreign architecture library
+# packages that we're going to link against. Everything
+# here should be a -dev package. Binaries belong earlier
+RUN DEBIAN_FRONTEND=noninteractive \
+ apt-get install -y --no-install-recommends \
+ libxml2-dev:::ARCH:: \
+ libncurses5-dev:::ARCH:: \
+ libreadline-dev:::ARCH:: \
+ zlib1g-dev:::ARCH:: \
+ libgcrypt20-dev:::ARCH:: \
+ libgnutls28-dev:::ARCH:: \
+ libavahi-client-dev:::ARCH:: \
+ libsasl2-dev:::ARCH:: \
+ libparted-dev:::ARCH:: \
+ libdevmapper-dev:::ARCH:: \
+ uuid-dev:::ARCH:: \
+ libudev-dev:::ARCH:: \
+ libpciaccess-dev:::ARCH:: \
+ libpolkit-gobject-1-dev:::ARCH:: \
+ libcap-ng-dev:::ARCH:: \
+ libnl-3-dev:::ARCH:: \
+ libnl-route-3-dev:::ARCH:: \
+ libyajl-dev:::ARCH:: \
+ libpcap0.8-dev:::ARCH:: \
+ libsanlock-dev:::ARCH:: \
+ libaudit-dev:::ARCH:: \
+ libselinux1-dev:::ARCH:: \
+ libapparmor-dev:::ARCH:: \
+ libdbus-1-dev:::ARCH:: \
+ librbd-dev:::ARCH:: \
+ librados-dev:::ARCH:: \
+ libfuse-dev:::ARCH:: \
+ libssh2-1-dev:::ARCH:: \
+ libcurl4-gnutls-dev:::ARCH:: \
+ libacl1-dev:::ARCH:: \
+ libiscsi-dev:::ARCH:: \
+ xfslibs-dev:::ARCH:: \
+ libssh-dev:::ARCH:: \
+ libgnutls28-dev:::ARCH::
+
+# Tell libvirt which architecture we want to target
+ENV LIBVIRT_CONFIGURE_OPTS "--host=::ABI:: --build=x86_64-linux-gnu --target=::ABI::"
+
+# Tell pkg-config where to find the non-native .pc files
+ENV PKG_CONFIG_LIBDIR=/usr/lib/::ABI::/pkgconfig
--
2.20.1
5 years, 9 months
[libvirt] [PULL 00/14] Ui 20190205 patches
by Gerd Hoffmann
The following changes since commit 773c4a6228fd910556cee2d477ee56c591a30000:
test-filter-mirror: pass UNIX domain socket through fd (2019-02-04 16:03:20 +0000)
are available in the git repository at:
git://git.kraxel.org/qemu tags/ui-20190205-pull-request
for you to fetch changes up to 19c1b9fd3dd5955893c0d3c187a4180313e9a0f1:
keymap: fix keyup mappings (2019-02-05 10:45:44 +0100)
----------------------------------------------------------------
ui: add kbd stats tracker.
ui: gtk scroll fixes.
ui: egl cursor scale fix.
ui: more sdl1 cleanup.
----------------------------------------------------------------
Brendan Shanks (1):
ui/cocoa.m: Fix macOS 10.14 deprecation warnings
Chen Zhang (1):
ui/egl-helpers: Augment parameter list of egl_texture_blend() to
convey scales of viewport
Gerd Hoffmann (8):
kbd-state: add keyboard state tracker
sdl2: remove sdl2_reset_keys() function
kbd-state: use state tracker for sdl2
sdl2: use only QKeyCode in sdl2_process_key()
kbd-state: use state tracker for gtk
kbd-state: use state tracker for vnc
keymap: pass full keyboard state to keysym2scancode
keymap: fix keyup mappings
Sergio Lopez (2):
ui: don't send any event if delta_y == 0
ui: listen for GDK_SMOOTH_SCROLL events
Thomas Huth (2):
Remove deprecated -no-frame option
ui/sdl_keysym: Remove obsolete SDL1.2 related code
include/sysemu/sysemu.h | 1 -
include/ui/egl-helpers.h | 2 +-
include/ui/gtk.h | 2 +
include/ui/kbd-state.h | 101 +++++++++++++++++
include/ui/sdl2.h | 3 +-
ui/keymaps.h | 3 +-
ui/sdl_keysym.h | 278 -----------------------------------------------
ui/vnc.h | 5 +-
ui/curses.c | 2 +-
ui/egl-headless.c | 3 +-
ui/egl-helpers.c | 9 +-
ui/gtk-egl.c | 3 +-
ui/gtk.c | 43 ++------
ui/kbd-state.c | 130 ++++++++++++++++++++++
ui/keymaps.c | 55 ++++++----
ui/sdl2-input.c | 50 +--------
ui/sdl2.c | 12 +-
ui/spice-display.c | 2 +-
ui/vnc.c | 119 ++++++--------------
vl.c | 23 +---
qemu-deprecated.texi | 6 -
qemu-options.hx | 11 --
ui/Makefile.objs | 2 +-
ui/cocoa.m | 28 ++++-
24 files changed, 360 insertions(+), 533 deletions(-)
create mode 100644 include/ui/kbd-state.h
delete mode 100644 ui/sdl_keysym.h
create mode 100644 ui/kbd-state.c
--
2.9.3
5 years, 9 months
[libvirt] [PATCH 00/10] snapshot: misc fixes
by Nikolay Shirokovskiy
The patch series aims to uniformly handle snapshot attribute for disks from
multiple places - snapshot definitions, domain definitions, snapshot operation
and defaults which is done in [1] utimately. Patch [2] makes a step towards
this goal. Other patches are fixes along the way that disables some invalid
cases on conversely enable previously disable valid cases.
The patches with most reasoning ([2] and [3]) are effectively revert Eric's
patch f9670bf thus I hope Eric will take a look.
Nikolay Shirokovskiy (10):
conf: snapshot: fix comment in _virDomainSnapshotDef
conf: snapshot: don't pass flags from different family
conf: snapshot: check disk with path on parse
conf: snapshot: align exernal/internal snapshot the same way [2]
conf: snapshot: remove snapshot mode checking from disk align [3]
conf: virDomainSnapshotAlignDisks: use convinient variable
qemu: disable internal snapshot of readonly disk
qemu: snapshot: fix for case of disk with empty source
qemu: snapshot: align disks consistently [1]
conf: snapshot: make disk aligns same on redefinition
src/conf/domain_conf.c | 6 +--
src/conf/snapshot_conf.c | 103 ++++++++++++++++++++++-------------------------
src/conf/snapshot_conf.h | 5 +--
src/qemu/qemu_driver.c | 27 ++++++++++---
src/test/test_driver.c | 5 +--
5 files changed, 74 insertions(+), 72 deletions(-)
--
1.8.3.1
5 years, 9 months
[libvirt] [PULL 1/8] qemu-nbd: Deprecate qemu-nbd --partition
by Eric Blake
The existing qemu-nbd --partition code claims to handle logical
partitions up to 8, since its introduction in 2008 (commit 7a5ca86).
However, the implementation is bogus (actual MBR logical partitions
form a sort of linked list, with one partition per extended table
entry, rather than four logical partitions in a single extended
table), making the code unlikely to work for anything beyond -P5 on
actual guest images. What's more, the code does not support GPT
partitions, which are becoming more popular, and maintaining device
subsetting in both NBD and the raw device is unnecessary duplication
of effort (even if it is not too difficult).
Note that obtaining the offsets of a partition (MBR or GPT) can be
learned by using 'qemu-nbd -c /dev/nbd0 file.qcow2 && sfdisk --dump
/dev/nbd0', but by the time you've done that, you might as well
just mount /dev/nbd0p1 that the kernel creates for you instead of
bothering with qemu exporting a subset. Or, keeping to just
user-space code, use nbdkit's partition filter, which has already
known both GPT and primary MBR partitions for a while, and was
just recently enhanced to support arbitrary logical MBR parititions.
Start the clock on the deprecation cycle, with examples of how
to accomplish device subsetting without using -P.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
Message-Id: <20190125234837.2272-1-eblake(a)redhat.com>
Reviewed-by: Richard W.M. Jones <rjones(a)redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare(a)redhat.com>
---
qemu-deprecated.texi | 33 +++++++++++++++++++++++++++++++++
qemu-nbd.texi | 6 ++++--
qemu-nbd.c | 2 ++
3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 9cc20b365c5..8a6174df0c1 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -160,3 +160,36 @@ Example of legacy encoding:
The above, converted to the current supported format:
@code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}}
+
+@section Related binaries
+
+@subsection qemu-nbd --partition (since 4.0.0)
+
+The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
+can only handle MBR partitions, and has never correctly handled
+logical partitions beyond partition 5. If you know the offset and
+length of the partition (perhaps by using @code{sfdisk} within the
+guest), you can achieve the effect of exporting just that subset of
+the disk by use of the @option{--image-opts} option with a raw
+blockdev using the @code{offset} and @code{size} parameters layered on
+top of any other existing blockdev. For example, if partition 1 is
+100MiB long starting at 1MiB, the old command:
+
+@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
+
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
+
+Alternatively, the @code{nbdkit} project provides a more powerful
+partition filter on top of its nbd plugin, which can be used to select
+an arbitrary MBR or GPT partition on top of any other full-image NBD
+export. Using this to rewrite the above example results in:
+
+@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &}
+@code{nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1}
+
+Note that if you are exposing the export via /dev/nbd0, it is easier
+to just export the entire image and then mount only /dev/nbd0p1 than
+it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
+subset of the image.
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 386bece4680..d0c51828149 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -56,8 +56,10 @@ auto-detecting.
@item -r, --read-only
Export the disk as read-only.
@item -P, --partition=@var{num}
-Only expose MBR partition @var{num}. Understands physical partitions
-1-4 and logical partitions 5-8.
+Deprecated: Only expose MBR partition @var{num}. Understands physical
+partitions 1-4 and logical partition 5. New code should instead use
+@option{--image-opts} with the raw driver wrapping a subset of the
+original image.
@item -B, --bitmap=@var{name}
If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 1f7b2a03f5d..00c07fd27ea 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -787,6 +787,8 @@ int main(int argc, char **argv)
flags &= ~BDRV_O_RDWR;
break;
case 'P':
+ warn_report("The '-P' option is deprecated; use --image-opts with "
+ "a raw device wrapper for subset exports instead");
if (qemu_strtoi(optarg, NULL, 0, &partition) < 0 ||
partition < 1 || partition > 8) {
error_report("Invalid partition '%s'", optarg);
--
2.20.1
5 years, 9 months
[libvirt] [PATCH RFC] qemu: caps: Don't try to ask for CAP_DAC_OVERRIDE if non-root
by Peter Krempa
It will not work. This breaks qemu capabilities probing as a user.
---
src/qemu/qemu_capabilities.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7ed5f94803..81ef0357e7 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4524,7 +4524,8 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
#if WITH_CAPNG
/* QEMU might run into permission issues, e.g. /dev/sev (0600), override
* them just for the purpose of probing */
- virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE);
+ if (geteuid() == 0)
+ virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE);
#endif
virCommandSetGID(cmd->cmd, cmd->runGid);
--
2.20.1
5 years, 9 months