[libvirt] [PATCH 00/19] qemu_command: use more of VIR_AUTO*
by Ján Tomko
Ján Tomko (19):
qemuBuildSerialChrDeviceStr: rename cmd to buf
qemuBuildNumaArgStr: split variable declarations
qemuBuildHotpluggableCPUProps: use VIR_RETURN_PTR
qemuxml2xmltest: switch TPM tests to use latest caps
qemu: move TPM vaildation to qemuDomainDeviceDefValidateTPM
qemuBuildTPMBackendStr: format device and alias separately
qemu_command: switch to VIR_AUTOCLEAN for virBuffer
qemu_command: use VIR_AUTOPTR for virJSONValue
qemu_command: use VIR_AUTOFREE for variables used once
qemuBuildNetworkDriveURI: use VIR_AUTOPTR for virURI
qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE
qemuBuildRNGCommandLine: use VIR_AUTOFREE
qemuBuildSmpCommandLine: use virCommandAddArgBuffer directly
qemuBuildShmemCommandLine: add chardev variable
qemuBuildShmemCommandLine: use VIR_AUTOFREE for devstr
qemu_command: use VIR_AUTOUNREF
qemu_command: remove unnecessary labels and ret variables
qemuBuildCommandLine: use VIR_AUTO*
qemuBuildCommandLine: remove unnecessary error label
src/qemu/qemu_command.c | 1388 ++++++-----------
src/qemu/qemu_domain.c | 29 +-
...> tpm-emulator-tpm2-enc.x86_64-latest.xml} | 4 +-
...ml => tpm-emulator-tpm2.x86_64-latest.xml} | 4 +-
...tor.xml => tpm-emulator.x86_64-latest.xml} | 4 +-
... => tpm-passthrough-crb.x86_64-latest.xml} | 4 +-
....xml => tpm-passthrough.x86_64-latest.xml} | 4 +-
tests/qemuxml2xmltest.c | 10 +-
8 files changed, 545 insertions(+), 902 deletions(-)
rename tests/qemuxml2xmloutdata/{tpm-emulator-tpm2-enc.xml => tpm-emulator-tpm2-enc.x86_64-latest.xml} (89%)
rename tests/qemuxml2xmloutdata/{tpm-emulator-tpm2.xml => tpm-emulator-tpm2.x86_64-latest.xml} (89%)
rename tests/qemuxml2xmloutdata/{tpm-emulator.xml => tpm-emulator.x86_64-latest.xml} (89%)
rename tests/qemuxml2xmloutdata/{tpm-passthrough-crb.xml => tpm-passthrough-crb.x86_64-latest.xml} (89%)
rename tests/qemuxml2xmloutdata/{tpm-passthrough.xml => tpm-passthrough.x86_64-latest.xml} (89%)
--
2.19.2
5 years, 3 months
[libvirt] [PATCH] api: fix typo in virDomainGetGuestInfo docs
by Ján Tomko
s/strign/string/
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Pushed as trivial.
src/libvirt-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 704754ac15..cea4d2c11b 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12224,7 +12224,7 @@ virDomainSetVcpu(virDomainPtr domain,
* The reported data depends on the guest agent implementation. The information
* is returned as an array of typed parameters containing the individual
* parameters. The parameter name for each information field consists of a
- * dot-separated strign containing the name of the requested group followed by
+ * dot-separated string containing the name of the requested group followed by
* a group-specific description of the statistic value.
*
* The information groups are enabled using the @types parameter which is a
--
2.20.1
5 years, 3 months
[libvirt] [RFC PATCH 0/2] qemu: Enable -blockdev [READ ME!] (blockdev-add saga finale?)
by Peter Krempa
With the patches I've posted to the list libvirt should be mostly
prepared to use -blockdev instead of -drive to specify disk images.
There's one gothcha though. Internal snapshots don't work due to qemu
considering every monitor-owned node for snapshot as well. With blockdev
everything became monitor-owned including the 'file' nodes which are
definitely not snapshottable. Even when qemu fixes that bug I don't
think it will be introspectable.
Our options are either to wait for the qemu fix and then try to detect
it somehow, perhaps as a version check (yuck), or go ahead and inform
users to upgrade to a newer qemu afterwards.
Any other ideas or suggestions?
Peter Krempa (2):
qemu: caps: Add capability for dynamic 'auto-read-only' support for
files
qemu: enable blockdev support
src/qemu/qemu_capabilities.c | 5 +
src/qemu/qemu_capabilities.h | 1 +
.../caps_4.1.0.x86_64.xml | 2 +
.../controller-virtio-scsi.x86_64-latest.args | 35 +++--
.../disk-aio.x86_64-latest.args | 19 ++-
...-backing-chains-noindex.x86_64-latest.args | 145 +++++++++++++++---
.../disk-cache.x86_64-latest.args | 50 ++++--
.../disk-cdrom-network.x86_64-latest.args | 32 ++--
.../disk-cdrom-tray.x86_64-latest.args | 24 ++-
.../disk-cdrom.x86_64-latest.args | 21 +--
.../disk-copy_on_read.x86_64-latest.args | 19 ++-
.../disk-detect-zeroes.x86_64-latest.args | 17 +-
.../disk-error-policy.x86_64-latest.args | 30 ++--
.../disk-floppy-q35-2_11.x86_64-latest.args | 14 +-
.../disk-floppy-q35-2_9.x86_64-latest.args | 14 +-
.../disk-floppy.x86_64-latest.args | 21 ++-
.../disk-network-gluster.x86_64-latest.args | 32 ++--
.../disk-network-iscsi.x86_64-latest.args | 58 ++++---
.../disk-network-nbd.x86_64-latest.args | 41 +++--
.../disk-network-rbd.x86_64-latest.args | 67 +++++---
.../disk-network-sheepdog.x86_64-latest.args | 16 +-
...isk-network-source-auth.x86_64-latest.args | 30 ++--
.../disk-network-tlsx509.x86_64-latest.args | 64 +++++---
.../disk-readonly-disk.x86_64-latest.args | 14 +-
.../disk-scsi-device-auto.x86_64-latest.args | 14 +-
.../disk-scsi.x86_64-latest.args | 35 +++--
.../disk-shared.x86_64-latest.args | 36 +++--
...irtio-scsi-reservations.x86_64-latest.args | 20 ++-
.../floppy-drive-fat.x86_64-latest.args | 7 +-
...egl-headless-rendernode.x86_64-latest.args | 7 +-
.../graphics-egl-headless.x86_64-latest.args | 7 +-
...threads-virtio-scsi-pci.x86_64-latest.args | 25 ++-
...y-hotplug-nvdimm-access.x86_64-latest.args | 7 +-
...ry-hotplug-nvdimm-align.x86_64-latest.args | 7 +-
...ry-hotplug-nvdimm-label.x86_64-latest.args | 7 +-
...ory-hotplug-nvdimm-pmem.x86_64-latest.args | 7 +-
...hotplug-nvdimm-readonly.x86_64-latest.args | 7 +-
.../memory-hotplug-nvdimm.x86_64-latest.args | 7 +-
...eo-bochs-display-device.x86_64-latest.args | 10 +-
...virtio-non-transitional.x86_64-latest.args | 7 +-
.../virtio-transitional.x86_64-latest.args | 7 +-
.../x86_64-pc-graphics.x86_64-latest.args | 8 +-
.../x86_64-pc-headless.x86_64-latest.args | 8 +-
.../x86_64-q35-graphics.x86_64-latest.args | 8 +-
.../x86_64-q35-headless.x86_64-latest.args | 8 +-
45 files changed, 714 insertions(+), 306 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH 00/10] qemu: Blockdevize external snapshot creation (blokcdev-add saga)
by Peter Krempa
Peter Krempa (10):
qemu: snapshot: Don't modify persistent XML if disk source is
different
qemu: driver: Remove dead code from
qemuDomainSnapshotUpdateDiskSources
qemu: Remove cleanup label in qemuDomainSnapshotPrepareDiskExternal
qemu: snapshot: Restrict file existance check only for local storage
qemu: Split out preparing of single snapshot from
qemuDomainSnapshotDiskDataCollect
qemu: Disband qemuDomainSnapshotCreateSingleDiskActive
qemu: Merge conditions depending on the 'reuse' flag in
qemuDomainSnapshotDiskDataCollectOne
qemu: snapshot: Skip overlay file creation/interogation if unsupported
qemu: Add -blockdev support for external snapshots
qemu: Defer support checks for external active snapshots to blockdev
code or qemu
src/qemu/qemu_driver.c | 333 ++++++++++++++++++++++++++---------------
1 file changed, 210 insertions(+), 123 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH 0/6] Honour use of /run instead of /var/run on distros
by Daniel P. Berrangé
Distros using systemd all use /run instead of /var/run. Libvirt has not
adapted, relying on the symlink between the two for compat. This is an
issue for UNIX sockets though, as systemd rewrites /var/run to /run
before binding to a socket and this means libvirtd cannot identify
sockets it is passed with old systemd.
Daniel P. Berrangé (6):
build: use $(COMMON_UNIT_VARS) for logging/locking systemd units
systemd: honour $runstatedir in socket unit files
build: honour $(runstatedir) in make rules
src: honour the RUNSTATEDIR variable in all code
build: support customization of runstatedir variable with old autoconf
rpm: set runstatedir to /run directory
configure.ac | 23 +++++++++++++++++
libvirt.spec.in | 15 +++++------
src/Makefile.am | 2 +-
src/bhyve/bhyve_utils.h | 2 +-
src/interface/interface_backend_netcf.c | 2 +-
src/interface/interface_backend_udev.c | 2 +-
src/libvirt-admin.c | 2 +-
src/libxl/Makefile.inc.am | 4 +--
src/libxl/libxl_conf.h | 2 +-
src/locking/Makefile.inc.am | 20 ++++-----------
src/locking/lock_daemon.c | 18 +++++++-------
src/locking/lock_driver_lockd.c | 2 +-
src/locking/virtlockd-admin.socket.in | 2 +-
src/locking/virtlockd.pod | 8 +++---
src/locking/virtlockd.socket.in | 2 +-
src/logging/Makefile.inc.am | 16 +++---------
src/logging/log_daemon.c | 18 +++++++-------
src/logging/log_manager.c | 2 +-
src/logging/virtlogd-admin.socket.in | 2 +-
src/logging/virtlogd.pod | 8 +++---
src/logging/virtlogd.socket.in | 2 +-
src/lxc/Makefile.inc.am | 4 +--
src/lxc/lxc_conf.h | 2 +-
src/lxc/lxc_process.c | 2 +-
src/network/Makefile.inc.am | 4 +--
src/network/bridge_driver.c | 4 +--
src/network/leaseshelper.c | 2 +-
src/node_device/node_device_hal.c | 2 +-
src/node_device/node_device_udev.c | 2 +-
src/nwfilter/nwfilter_dhcpsnoop.c | 4 +--
src/nwfilter/nwfilter_driver.c | 4 +--
src/qemu/Makefile.inc.am | 8 +++---
src/qemu/qemu_conf.c | 4 +--
src/remote/Makefile.inc.am | 4 +++
src/remote/libvirtd-admin.socket.in | 2 +-
src/remote/libvirtd-ro.socket.in | 2 +-
src/remote/libvirtd.conf.in | 2 +-
src/remote/libvirtd.pod | 10 ++++----
src/remote/libvirtd.socket.in | 2 +-
src/remote/remote_daemon.c | 24 +++++++++---------
src/remote/remote_daemon_dispatch.c | 4 +--
src/remote/remote_driver.c | 6 +++++
src/remote/test_libvirtd.aug.in | 2 +-
src/secret/secret_driver.c | 2 +-
src/security/virt-aa-helper.c | 20 ++++++---------
src/storage/storage_driver.c | 2 +-
src/util/virhostdev.c | 2 +-
src/util/virpidfile.c | 8 +++---
src/util/virsystemd.c | 33 ++++++++++++++++---------
src/vz/vz_driver.c | 2 +-
50 files changed, 172 insertions(+), 151 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH] qemu: Use the same def when attaching device live and config
by wujing (O)
Patch 55ce6564634 caused a problem fixed in 1e0534a7702, described as below:
Some members are generated during XML parse (e.g. MAC address of
an interface); However, with current implementation, if we
are plugging a device both to persistent and live config,
we parse given XML twice: first time for live, second for config.
This is wrong then as the second time we are not guaranteed
to generate same values as we did for the first time.
To solve that, we should use the same def when attaching a device
config and live. And leave the current process unchanged when
using --config and --live separately.
Signed-off-by: Wu Jing <wujing42(a)huawei.com>
---
src/qemu/qemu_driver.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 617d7d5..eca54d0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8615,6 +8615,22 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
+ flags & VIR_DOMAIN_AFFECT_LIVE) {
+ /* If we are affecting both CONFIG and LIVE
+ * use the same xml of device preferentially
+ * to make the configuration consistent.
+ */
+ devLive = virDomainDeviceDefParse(xml, vm->def,
+ caps, driver->xmlopt,
+ parse_flags);
+ if (!devLive)
+ goto cleanup;
+ devConf = virDomainDeviceDefCopy(devLive, vm->def, caps, driver->xmlopt);
+ if (!devConf)
+ goto cleanup;
+ }
+
/* The config and live post processing address auto-generation algorithms
* rely on the correct vm->def or vm->newDef being passed, so call the
* device parse based on which definition is in use */
@@ -8623,7 +8639,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
if (!vmdef)
goto cleanup;
- if (!(devConf = virDomainDeviceDefParse(xml, vmdef, caps,
+ if (!devConf &&
+ !(devConf = virDomainDeviceDefParse(xml, vmdef, caps,
driver->xmlopt, parse_flags)))
goto cleanup;
@@ -8643,7 +8660,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- if (!(devLive = virDomainDeviceDefParse(xml, vm->def, caps,
+ if (!devLive &&
+ !(devLive = virDomainDeviceDefParse(xml, vm->def, caps,
driver->xmlopt, parse_flags)))
goto cleanup;
--
2.19.1
5 years, 3 months
Re: [libvirt] [PATCH] util: storage: drop VIR_STORAGE_FILE_AUTO_SAFE
by Yi Li
>> merge VIR_STORAGE_FILE_AUTO_SAFE/VIR_STORAGE_FILE_AUTO to VIR_STORAGE_FILE_AUTO
>> virStorageFileProbeFormatFromBuf will probe the backingStore format.
>>
>> Fix the booting issue when setting backingStore format (QCOW image) to RAW image.
>
>This description does not really describe what the problem is.
>
The Guest VM cann't boot correctly as below:
1: Guest VM disk info when shutdown
......
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='directsync' io='native'/>
<source file='/vms/images/.transient/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e'/>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
......
pls:
[root@***-130 ~]# qemu-img info /vms/images/.transient/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e
image: /vms/images/.transient/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 15M
cluster_size: 65536
backing file: /vms/images/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
[root@***-130 ~]# qemu-img info /vms/images/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e
image: /vms/images/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 1.2G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
2: After boot, the backingStore format is not expected
......
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='directsync' io='native'/>
<source file='/vms/images/.transient/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e'/>
<backingStore type='file' index='1'>
<format type='raw'/>
<source file='/vms/images/f6e5eb8b-7d81-443d-aab0-bb1cca1cf29e'/>
<backingStore/>
</backingStore>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
......
>>
>> Signed-off-by: Yi Li <yili(a)winhong.com>
>> ---
>> src/qemu/qemu_block.c | 2 --
>> src/util/virstoragefile.c | 4 +---
>> src/util/virstoragefile.h | 1 -
>> 3 files changed, 1 insertion(+), 6 deletions(-)
>>
>> @@ -4916,8 +4916,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
>> goto cleanup;
>>
>> if (backingFormat == VIR_STORAGE_FILE_AUTO)
>> - backingStore->format = VIR_STORAGE_FILE_RAW;
>> - else if (backingFormat == VIR_STORAGE_FILE_AUTO_SAFE)
>> backingStore->format = VIR_STORAGE_FILE_AUTO;
>
>I don't think we can do this safely. This code was added so that we
>never let qemu probe the image format. This was due to a security issue
>as a malicious guest could write a qcow2 or any other storage format
>header which has backing files into a raw volume. At new start this
>would be detected as the qcow2 or other format and qemu would open also
>the backing file. The guest then would gain access to un-allowed
>resources.
>
>While now qemu refuses writing some parts of the raw image if no format
>was specified I don't think we should remove this code. Users always
>shall use the correct format.
>
>NACK
5 years, 3 months
[libvirt] [PATCH 1/3] audio: omitting audiodev= parameter is only deprecated
by Kővágó, Zoltán
Unfortunately, changes introduced in af2041ed2d "audio: audiodev=
parameters no longer optional when -audiodev present" breaks backward
compatibility. This patch changes the error into a deprecation warning.
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu(a)gmail.com>
---
qemu-deprecated.texi | 7 +++++++
audio/audio.c | 8 ++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 00a4b6f350..9d74a1cfc0 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -72,6 +72,13 @@ backend settings instead of environment variables. To ease migration to
the new format, the ``-audiodev-help'' option can be used to convert
the current values of the environment variables to ``-audiodev'' options.
+@subsection Creating sound card devices and vnc without audiodev= property (since 4.2)
+
+When not using the deprecated legacy audio config, each sound card
+should specify an @code{audiodev=} property. Additionally, when using
+vnc, you should specify an @code{audiodev=} propery if you plan to
+transmit audio through the VNC protocol.
+
@subsection -mon ...,control=readline,pretty=on|off (since 4.1)
The @code{pretty=on|off} switch has no effect for HMP monitors, but is
diff --git a/audio/audio.c b/audio/audio.c
index 7d715332c9..e13addf922 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1412,8 +1412,9 @@ static AudioState *audio_init(Audiodev *dev, const char *name)
drvname = AudiodevDriver_str(dev->driver);
} else if (!QTAILQ_EMPTY(&audio_states)) {
if (!legacy_config) {
- dolog("You must specify an audiodev= for the device %s\n", name);
- exit(1);
+ dolog("Device %s: audiodev default parameter is deprecated, please "
+ "specify audiodev=%s\n", name,
+ QTAILQ_FIRST(&audio_states)->dev->id);
}
return QTAILQ_FIRST(&audio_states);
} else {
@@ -1548,8 +1549,7 @@ CaptureVoiceOut *AUD_add_capture(
if (!s) {
if (!legacy_config) {
- dolog("You must specify audiodev when trying to capture\n");
- return NULL;
+ dolog("Capturing without setting an audiodev is deprecated\n");
}
s = audio_init(NULL, NULL);
}
--
2.22.0
5 years, 3 months
[libvirt] [PATCH 00/14] Ignore backing files with inline authentication (blockdev-add saga)
by Peter Krempa
If a backing file string contains authentication data, many things can
break as libvirt is not tracking it since we use the secret driver for
this.
Stop considering such files as viable backing store entries.
Peter Krempa (14):
util: storage: Simplify cleanup path handling in
virStorageSourceParseBackingJSONInternal
util: storagefile: Remove cleanup label from
virStorageSourceParseBackingJSONiSCSI
util: storagefile: Simplify cleanup handling in
virStorageSourceParseBackingURI
util: storagefile: Simplify cleanup in
virStorageSourceParseBackingJSON
tests: viruri: Add test for password in URI userinfo
tests: storage: Refactor cleanup in testBackingParse
util: storage: Modify return value of virStorageSourceNewFromBacking
util: storagefile: Preserve return value in
virStorageSourceParseBackingJSONUriStr
util: storagefile: Modify arguments of
virStorageSourceNewFromBackingAbsolue
tests: virstorage: Allow testing return value of
virStorageSourceNewFromBackingAbsolute
util: storagefile: Add handling of unusable storage sources
util: storagefile: Clarify docs for '@report_broken' of
virStorageFileGetMetadata
util: storagefile: Don't traverse storage sources unusable by VM
util: storagefile: Flag backing store strings with authentication
src/storage/storage_util.c | 2 +-
src/util/virstoragefile.c | 215 ++++++++++++++++++++++---------------
src/util/virstoragefile.h | 7 +-
tests/qemublocktest.c | 3 +-
tests/virstoragetest.c | 66 +++++++++---
tests/viruritest.c | 1 +
6 files changed, 185 insertions(+), 109 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH] virsh: Allow graceful console shutdown
by Michal Privoznik
Currently, whenever there's a regular EOF on the console stream
or an error the virStreamAbort() is called regardless. While this
may not actually break anything, we should call virStreamFinish()
to let the daemon know we've successfully received all the data
and are shutting down the stream gracefully.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-console.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index a235a9a283..900faa5087 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -97,7 +97,8 @@ virConsoleHandleSignal(int sig ATTRIBUTE_UNUSED)
static void
-virConsoleShutdown(virConsolePtr con)
+virConsoleShutdown(virConsolePtr con,
+ bool graceful)
{
virErrorPtr err = virGetLastError();
@@ -105,10 +106,18 @@ virConsoleShutdown(virConsolePtr con)
virCopyLastError(&con->error);
if (con->st) {
+ int rc;
+
virStreamEventRemoveCallback(con->st);
- if (virStreamAbort(con->st) < 0)
+ if (graceful)
+ rc = virStreamFinish(con->st);
+ else
+ rc = virStreamAbort(con->st);
+
+ if (rc < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot terminate console stream"));
+ }
virStreamFree(con->st);
con->st = NULL;
}
@@ -160,7 +169,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (avail < 1024) {
if (VIR_REALLOC_N(con->streamToTerminal.data,
con->streamToTerminal.length + 1024) < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
con->streamToTerminal.length += 1024;
@@ -174,7 +183,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (got == -2)
goto cleanup; /* blocking */
if (got <= 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, got == 0);
goto cleanup;
}
con->streamToTerminal.offset += got;
@@ -193,7 +202,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (done == -2)
goto cleanup; /* blocking */
if (done < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, done == 0);
goto cleanup;
}
memmove(con->terminalToStream.data,
@@ -214,7 +223,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (events & VIR_STREAM_EVENT_ERROR ||
events & VIR_STREAM_EVENT_HANGUP) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
}
cleanup:
@@ -244,7 +253,7 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (avail < 1024) {
if (VIR_REALLOC_N(con->terminalToStream.data,
con->terminalToStream.length + 1024) < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
con->terminalToStream.length += 1024;
@@ -258,17 +267,17 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (got < 0) {
if (errno != EAGAIN) {
virReportSystemError(errno, "%s", _("cannot read from stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
}
goto cleanup;
}
if (got == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
if (con->terminalToStream.data[con->terminalToStream.offset] == con->escapeChar) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
@@ -281,13 +290,13 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (events & VIR_EVENT_HANDLE_ERROR) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IO error on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
if (events & VIR_EVENT_HANDLE_HANGUP) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
@@ -320,7 +329,7 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
if (done < 0) {
if (errno != EAGAIN) {
virReportSystemError(errno, "%s", _("cannot write to stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
}
goto cleanup;
}
@@ -342,13 +351,13 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
if (events & VIR_EVENT_HANDLE_ERROR) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IO error stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
if (events & VIR_EVENT_HANDLE_HANGUP) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, false);
goto cleanup;
}
@@ -487,7 +496,7 @@ virshRunConsole(vshControl *ctl,
ret = 0;
cleanup:
- virConsoleShutdown(con);
+ virConsoleShutdown(con, ret == 0);
if (ret < 0) {
vshResetLibvirtError();
--
2.21.0
5 years, 4 months