[libvirt] [PATCH] output status information during guest shutdown again
by Gerd v. Egidy
With SysV-init libvirt-guests wrote status information to the console
during shutdown of the guests.
Since the move to systemd libvirt-guests doesn't output this progress
information anymore. This patch brings back this feature.
It is helpful to show the admin what the system is waiting for and what
is left of the timeout (e.g. for calibrating the shutdown timing of a ups).
Rewriting the current line with \r doesn't work anymore in the context
of systemd. So always write new lines, but move to 5 second intervals
to avoid flooding the console.
---
tools/libvirt-guests.init.sh | 65 +++++++++++++++++++++++++++++++----------
tools/libvirt-guests.service.in | 1 +
2 files changed, 51 insertions(+), 15 deletions(-)
mode change 100644 => 100755 tools/libvirt-guests.init.sh
diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
old mode 100644
new mode 100755
index d5d42d6..0ffbb41
--- a/tools/libvirt-guests.init.sh
+++ b/tools/libvirt-guests.init.sh
@@ -225,22 +225,27 @@ suspend_guest()
name=$(guest_name "$uri" "$guest")
label=$(eval_gettext "Suspending \$name: ")
bypass=
+ slept=0
test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
- printf %s "$label"
+ printf '%s%-12s\n' "$label" "..."
run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
virsh_pid=$!
while true; do
sleep 1
kill -0 "$virsh_pid" >/dev/null 2>&1 || break
- progress=$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
- awk '/^Data processed:/{print $3, $4}')
- if [ -n "$progress" ]; then
- printf '\r%s%12s ' "$label" "$progress"
- else
- printf '\r%s%-12s ' "$label" "..."
+
+ slept=$(($slept + 1))
+ if [ $(($slept%5)) -eq 0 ]; then
+ progress=$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
+ awk '/^Data processed:/{print $3, $4}')
+ if [ -n "$progress" ]; then
+ printf '%s%12s\n' "$label" "$progress"
+ else
+ printf '%s%-12s\n' "$label" "..."
+ fi
fi
done
- retval wait "$virsh_pid" && printf '\r%s%-12s\n' "$label" "$(gettext "done")"
+ retval wait "$virsh_pid" && printf '%s%-12s\n' "$label" "$(gettext "done")"
}
# shutdown_guest URI GUEST
@@ -252,30 +257,41 @@ shutdown_guest()
guest=$2
name=$(guest_name "$uri" "$guest")
- label=$(eval_gettext "Shutting down \$name: ")
- printf %s "$label"
+ eval_gettext "Starting shutdown on guest: \$name"
+ echo
retval run_virsh "$uri" shutdown "$guest" >/dev/null || return
timeout=$SHUTDOWN_TIMEOUT
check_timeout=false
if [ $timeout -gt 0 ]; then
check_timeout=true
+ format=$(eval_gettext "Waiting for guest %s to shut down, %4d seconds left\n")
+ else
+ slept=0
+ format=$(eval_gettext "Waiting for guest %s to shut down\n")
fi
while ! $check_timeout || [ "$timeout" -gt 0 ]; do
sleep 1
guest_is_on "$uri" "$guest" || return
"$guest_running" || break
+
if $check_timeout; then
- timeout=$((timeout - 1))
- printf '\r%s%-12d ' "$label" "$timeout"
+ if [ $(($timeout%5)) -eq 0 ]; then
+ printf "$format" "$name" "$timeout"
+ fi
+ timeout=$(($timeout - 1))
+ else
+ slept=$(($slept + 1))
+ if [ $(($slept%5)) -eq 0 ]; then
+ printf "$format" "$name"
+ fi
fi
done
if guest_is_on "$uri" "$guest"; then
if "$guest_running"; then
- printf '\r%s%-12s\n' "$label" \
- "$(gettext "failed to shutdown in time")"
+ eval_gettext "Shutdown of guest \$name failed to complete in time."
else
- printf '\r%s%-12s\n' "$label" "$(gettext "done")"
+ eval_gettext "Shutdown of guest \$name complete."
fi
fi
}
@@ -356,6 +372,10 @@ shutdown_guests_parallel()
timeout=$SHUTDOWN_TIMEOUT
if [ $timeout -gt 0 ]; then
check_timeout=true
+ format=$(eval_gettext "Waiting for %d guests to shut down, %4d seconds left\n")
+ else
+ slept=0
+ format=$(eval_gettext "Waiting for %d guests to shut down\n")
fi
while [ -n "$on_shutdown" ] || [ -n "$guests" ]; do
while [ -n "$guests" ] &&
@@ -368,14 +388,29 @@ shutdown_guests_parallel()
on_shutdown="$on_shutdown $guest"
done
sleep 1
+
+ set -- $guests
+ guestcount=$#
+ set -- $on_shutdown
+ shutdowncount=$#
+
if $check_timeout; then
+ if [ $(($timeout%5)) -eq 0 ]; then
+ printf "$format" $(($guestcount+$shutdowncount)) "$timeout"
+ fi
timeout=$(($timeout - 1))
if [ $timeout -le 0 ]; then
eval_gettext "Timeout expired while shutting down domains"; echo
RETVAL=1
return
fi
+ else
+ slept=$(($slept + 1))
+ if [ $(($slept%5)) -eq 0 ]; then
+ printf "$format" $(($guestcount+$shutdowncount))
+ fi
fi
+
on_shutdown_prev=$on_shutdown
on_shutdown=$(check_guests_shutdown "$uri" "$on_shutdown")
print_guests_shutdown "$uri" "$on_shutdown_prev" "$on_shutdown"
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index db28f3f..0f0c41c 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -10,6 +10,7 @@ ExecStart=/etc/init.d/libvirt-guests start
ExecStop=/etc/init.d/libvirt-guests stop
Type=oneshot
RemainAfterExit=yes
+StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH v2.1 00/21] Supports for emulator-pin and emulator-bandwidth
by Hu Tao
This series adds support of emulator-pin to pin emulator threads on
specified physical CPUs, and emulator-bandwidth to control physical
CPU bandwidth for emulator threads.
changes:
v2.1:
- rebase
- include emulator-bandwidth patches
- minor fix of virCgroupAddTaskStrController
v2:
- rename hypervisor to emulator all through the series
- no Flags-suffix for new APIs
- reduce code duplication
- rollback to old vcpupin def if error
Hu Tao (12):
Introduce the function virCgroupMoveTask
add function bitmapFromBytemap() to convert bytemap to bitmap
refactor virDomainVcpuPinAdd()
updates of some vcpupin related functions
Enable cpuset cgroup and synchronous vcpupin info to cgroup.
Change virDomainVcpuPinDefParseXML to support parsing emulatorpin
qemu: support emulator pinning
Add a new function vshPrintPinInfo.
new command emulatorpin
limit cpu bandwidth only for vcpus
qemu: introduce period/quota tuning for emulator
new interface to control emulator_period/emulator_quota
Tang Chen (6):
Support emulatorpin xml parse.
qemu: synchronize emulatorpin info to cgroup
Add qemuProcessSetEmulatorAffinites and set emulator threads
affinities
Introduce virDomainPinEmulator and virDomainGetEmulatorPinInfo
functions.
Introduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel
functions
remote: introduce emulator pinning RPCs
Wen Congyang (3):
Introduce the function virCgroupForEmulator
create a new cgroup and move all emulator threads to the new cgroup
qemu: support of emulator_period and emulator_quota's modification
daemon/remote.c | 91 ++++
docs/formatdomain.html.in | 33 ++
docs/schemas/domaincommon.rng | 17 +
include/libvirt/libvirt.h.in | 34 +-
src/conf/domain_conf.c | 300 ++++++++++---
src/conf/domain_conf.h | 17 +-
src/driver.h | 12 +
src/libvirt.c | 147 +++++++
src/libvirt_private.syms | 9 +
src/libvirt_public.syms | 2 +
src/libxl/libxl_driver.c | 13 +-
src/qemu/qemu_cgroup.c | 173 ++++++--
src/qemu/qemu_cgroup.h | 7 +
src/qemu/qemu_driver.c | 523 +++++++++++++++++++----
src/qemu/qemu_process.c | 60 ++-
src/remote/remote_driver.c | 99 +++++
src/remote/remote_protocol.x | 21 +-
src/remote_protocol-structs | 22 +
src/util/cgroup.c | 187 +++++++-
src/util/cgroup.h | 15 +
src/xen/xend_internal.c | 13 +-
tests/qemuxml2argvdata/qemuxml2argv-cputune.xml | 1 +
tools/virsh-domain.c | 253 ++++++++++-
tools/virsh.pod | 27 +-
24 files changed, 1868 insertions(+), 208 deletions(-)
--
1.7.10.2
12 years, 3 months
[libvirt] [PATCH V3 0/3] Improve netlink to support all protocols.
by Tang Chen
These patches improved libvirt to support all netlink protocols,
and also introduced a new netlink service to listen to hotplug
events.
Tang Chen (3):
Improve netlink to support all protocol.
Introduce virNetlinkEventServiceStopAll() to stop all netlink
services.
Add uevent netlink service.
daemon/libvirtd.c | 12 ++-
src/libvirt_private.syms | 1 +
src/util/virnetdev.c | 6 +-
src/util/virnetdevmacvlan.c | 12 ++-
src/util/virnetdevvportprofile.c | 7 +-
src/util/virnetlink.c | 220 ++++++++++++++++++++++++++++++--------
src/util/virnetlink.h | 22 ++--
7 files changed, 218 insertions(+), 62 deletions(-)
--
1.7.10.1
12 years, 3 months
[libvirt] [PATCH 0/2] Fix thrashing of user's known_hosts file.
by Peter Krempa
Libvirt tried to use the user's default known_hosts file in .ssh/known_hosts
for it's purposes, but libssh2 thrashes it if it contains unsupported keys.
Whith this patchset, libvirt will maintain it's own known_hosts file in it's
config directory.
Peter Krempa (2):
libssh2_session: Add support for creating known_hosts file
client: Change default location of known_hosts file for libssh2 layer
src/rpc/virnetclient.c | 17 ++++++++++-------
src/rpc/virnetsocket.c | 4 ++--
src/rpc/virnetsshsession.c | 26 ++++++++++++++++----------
src/rpc/virnetsshsession.h | 9 +++++++--
4 files changed, 35 insertions(+), 21 deletions(-)
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] virsh: don't print error info when snapshot xml is not changed
by Guannan Ren
If xml is not changed, error message is printed.
So check ret value instead of edit variable for error message.
---
tools/virsh-snapshot.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index aff91d3..5d84f7a 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
_("Snapshot %s XML configuration not changed.\n"), \
name); \
ret = true; \
- goto cleanup; \
+ goto edit_cleanup; \
}
#define EDIT_DEFINE \
(strstr(doc, "<state>disk-snapshot</state>") ? \
@@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
ret = true;
cleanup:
+ if (!ret)
+ vshError(ctl, _("Failed to update %s"), name);
if (edited)
virDomainSnapshotFree(edited);
- else
- vshError(ctl, _("Failed to update %s"), name);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (dom)
--
1.7.10.1
12 years, 3 months
[libvirt] [PATCHv6 0/2] Rework of Disk Geometry Support
by Viktor Mihajlovski
With qemu it is possible to override the geometry (cylinders, heads,
sectors) of disks.
This series adds a new XML tag for geometry and the related
support in the qemu driver.
V2 Changes:
Refactor into the generic domain configuration/XML support for disk
geometry and a qemu specific part with the testcase
V3 Changes:
1. Use virReportError instead of custom xxxReportError.
2. Moved the geometry element to diskspec, so it applies to all kind
of disks.
V4 Changes:
Rebase for libvirt 0.10.0 freeze.
V5 Changes:
Corrected qemuxml2argvtest invocation. Oversight after rebase.
V6 Changes:
The geometry info was incorrectly processed only for block and file
based disks. Fixed.
J.B. Joret (2):
Support for Disk Geometry Override
qemu: Disk Geometry Override Support
docs/formatdomain.html.in | 25 +++++++
docs/schemas/domaincommon.rng | 25 +++++++
src/conf/domain_conf.c | 71 ++++++++++++++++++++
src/conf/domain_conf.h | 17 +++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 56 +++++++++++++++
.../qemuxml2argv-disk-geometry.args | 4 +
.../qemuxml2argv-disk-geometry.xml | 26 +++++++
tests/qemuxml2argvtest.c | 2 +
9 files changed, 228 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.xml
12 years, 3 months
[libvirt] [PATCH] atomic: mark header functions static
by Eric Blake
When gcc atomic intrinsics are not available (such as on RHEL 5
with gcc 4.1.2), we were getting link errors due to multiple
definitions:
./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor':
/home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor'
./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here
Solve this by conditionally marking the functions static (the
condition avoids falling foul of gcc warnings about unused
static function declarations).
* src/util/viratomic.h: When not using gcc intrinsics, use static
functions to avoid linker errors on duplicate functions.
---
Pushing under the build-breaker rule. Tested on both RHEL 5
and modern gcc of F17.
Oh, and I just noticed my indentation is off, while preparing
this email; I'll squash in the whitespace fix before pushing.
src/util/viratomic.h | 75 ++++++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 34 deletions(-)
diff --git a/src/util/viratomic.h b/src/util/viratomic.h
index fa0a89a..95c7f5c 100644
--- a/src/util/viratomic.h
+++ b/src/util/viratomic.h
@@ -28,6 +28,12 @@
# include "internal.h"
+# ifdef VIR_ATOMIC_OPS_GCC
+# define VIR_STATIC /* Nothing; we just never define the functions */
+# else
+# define VIR_STATIC static
+# endif
+
/**
* virAtomicIntGet:
* Gets the current value of atomic.
@@ -35,7 +41,7 @@
* This call acts as a full compiler and hardware memory barrier
* (before the get)
*/
-int virAtomicIntGet(volatile int *atomic)
+VIR_STATIC int virAtomicIntGet(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
@@ -45,8 +51,8 @@ int virAtomicIntGet(volatile int *atomic)
* This call acts as a full compiler and hardware memory barrier
* (after the set)
*/
-void virAtomicIntSet(volatile int *atomic,
- int newval)
+VIR_STATIC void virAtomicIntSet(volatile int *atomic,
+ int newval)
ATTRIBUTE_NONNULL(1);
/**
@@ -58,7 +64,7 @@ void virAtomicIntSet(volatile int *atomic,
*
* This call acts as a full compiler and hardware memory barrier.
*/
-int virAtomicIntInc(volatile int *atomic)
+VIR_STATIC int virAtomicIntInc(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
@@ -70,7 +76,7 @@ int virAtomicIntInc(volatile int *atomic)
*
* This call acts as a full compiler and hardware memory barrier.
*/
-bool virAtomicIntDecAndTest(volatile int *atomic)
+VIR_STATIC bool virAtomicIntDecAndTest(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
@@ -86,9 +92,9 @@ bool virAtomicIntDecAndTest(volatile int *atomic)
*
* This call acts as a full compiler and hardware memory barrier.
*/
-bool virAtomicIntCompareExchange(volatile int *atomic,
- int oldval,
- int newval)
+VIR_STATIC bool virAtomicIntCompareExchange(volatile int *atomic,
+ int oldval,
+ int newval)
ATTRIBUTE_NONNULL(1);
/**
@@ -100,8 +106,8 @@ bool virAtomicIntCompareExchange(volatile int *atomic,
*
* This call acts as a full compiler and hardware memory barrier.
*/
-int virAtomicIntAdd(volatile int *atomic,
- int val)
+VIR_STATIC int virAtomicIntAdd(volatile int *atomic,
+ int val)
ATTRIBUTE_NONNULL(1);
/**
@@ -114,8 +120,8 @@ int virAtomicIntAdd(volatile int *atomic,
* Think of this operation as an atomic version of
* { tmp = *atomic; *atomic &= val; return tmp; }
*/
-unsigned int virAtomicIntAnd(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntAnd(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
/**
@@ -128,8 +134,8 @@ unsigned int virAtomicIntAnd(volatile unsigned int *atomic,
*
* This call acts as a full compiler and hardware memory barrier.
*/
-unsigned int virAtomicIntOr(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntOr(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
/**
@@ -142,10 +148,11 @@ unsigned int virAtomicIntOr(volatile unsigned int *atomic,
*
* This call acts as a full compiler and hardware memory barrier.
*/
-unsigned int virAtomicIntXor(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntXor(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
+# undef VIR_STATIC
# ifdef VIR_ATOMIC_OPS_GCC
@@ -224,14 +231,14 @@ unsigned int virAtomicIntXor(volatile unsigned int *atomic,
/*
* http://msdn.microsoft.com/en-us/library/ms684122(v=vs.85).aspx
*/
-inline int
+static inline int
virAtomicIntGet(volatile int *atomic)
{
MemoryBarrier();
return *atomic;
}
-inline void
+static inline void
virAtomicIntSet(volatile int *atomic,
int newval)
{
@@ -239,19 +246,19 @@ virAtomicIntSet(volatile int *atomic,
MemoryBarrier();
}
-inline int
+static inline int
virAtomicIntInc(volatile int *atomic)
{
return InterlockedIncrement((volatile LONG *)atomic);
}
-inline bool
+static inline bool
virAtomicIntDecAndTest(volatile int *atomic)
{
return InterlockedDecrement((volatile LONG *)atomic) == 0;
}
-inline bool
+static inline bool
virAtomicIntCompareExchange(volatile int *atomic,
int oldval,
int newval)
@@ -259,28 +266,28 @@ virAtomicIntCompareExchange(volatile int *atomic,
return InterlockedCompareExchange((volatile LONG *)atomic, newval, oldval) == oldval;
}
-inline int
+static inline int
virAtomicIntAdd(volatile int *atomic,
int val)
{
return InterlockedExchangeAdd((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntAnd(volatile unsigned int *atomic,
unsigned int val)
{
return InterlockedAnd((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntOr(volatile unsigned int *atomic,
unsigned int val)
{
return InterlockedOr((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntXor(volatile unsigned int *atomic,
unsigned int val)
{
@@ -294,7 +301,7 @@ virAtomicIntXor(volatile unsigned int *atomic,
extern pthread_mutex_t virAtomicLock;
-inline int
+static inline int
virAtomicIntGet(volatile int *atomic)
{
int value;
@@ -306,7 +313,7 @@ virAtomicIntGet(volatile int *atomic)
return value;
}
-inline void
+static inline void
virAtomicIntSet(volatile int *atomic,
int value)
{
@@ -315,7 +322,7 @@ virAtomicIntSet(volatile int *atomic,
pthread_mutex_unlock(&virAtomicLock);
}
-inline int
+static inline int
virAtomicIntInc(volatile int *atomic)
{
int value;
@@ -327,7 +334,7 @@ virAtomicIntInc(volatile int *atomic)
return value;
}
-inline bool
+static inline bool
virAtomicIntDecAndTest(volatile int *atomic)
{
bool is_zero;
@@ -339,7 +346,7 @@ virAtomicIntDecAndTest(volatile int *atomic)
return is_zero;
}
-inline bool
+static inline bool
virAtomicIntCompareExchange(volatile int *atomic,
int oldval,
int newval)
@@ -356,7 +363,7 @@ virAtomicIntCompareExchange(volatile int *atomic,
return success;
}
-inline int
+static inline int
virAtomicIntAdd(volatile int *atomic,
int val)
{
@@ -370,7 +377,7 @@ virAtomicIntAdd(volatile int *atomic,
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntAnd(volatile unsigned int *atomic,
unsigned int val)
{
@@ -384,7 +391,7 @@ virAtomicIntAnd(volatile unsigned int *atomic,
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntOr(volatile unsigned int *atomic,
unsigned int val)
{
@@ -398,7 +405,7 @@ virAtomicIntOr(volatile unsigned int *atomic,
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntXor(volatile unsigned int *atomic,
unsigned int val)
{
--
1.7.11.4
12 years, 3 months
[libvirt] [PATCH 0/4] Improve netlink to support all protocols.
by Tang Chen
These patches improved libvirt to support all netlink protocols,
and also introduced a new netlink service to listen to hotplug
events.
Tang Chen (4):
Improve netlink to support all protocol.
Introduce virNetlinkEventServiceStopAll() to stop all netlink
services in libvirt.
Add uevent netlink service.
DEBUG: print out netlink message.
daemon/libvirtd.c | 12 +-
src/libvirt_private.syms | 1 +
src/util/virnetdev.c | 6 +-
src/util/virnetdevmacvlan.c | 12 +-
src/util/virnetdevvportprofile.c | 7 +-
src/util/virnetlink.c | 230 +++++++++++++++++++++++++++++++-------
src/util/virnetlink.h | 22 ++--
7 files changed, 229 insertions(+), 61 deletions(-)
--
1.7.10.1
12 years, 3 months
[libvirt] building on RHEL 5 currently broken
by Eric Blake
Just a quick heads-up (I'll fix it later, when I have more time): I just
learned commit 350583c85 broke builds on RHEL 5, because of the use of
AS_VERSION_COMPARE in configure.ac which was not available in older
autoconf 2.59.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
12 years, 3 months
Re: [libvirt] [PATCH v1 1/2] Backcompt for console devices in virDomainDeviceInfoIterate
by Li Zhang
Hi Daniel and Eric,
Would you please help review this patch?
This is one bug fix for pSeries.
x86 doesn't have such a problem, because serial devices has no bus
address on x86.
I think this won't break x86.
On 2012年08月08日 22:52, Li Zhang wrote:
> Histrically, the first <console> element is treated as the
> alias of a <serial> device. In the virDomainDeviceInfoIterate,
> This situation is not considered. It still handles the first <console>
> element as another devices, which means that for console[0] with
> serial targetType, it calls callback function another time.
> It will cause the problem of address conflicts when assigning
> spapr-vio address for serial device on pSeries guest.
>
> The following describes the problem:
>
> For pSeries guest, the serial configuration in the xml file
> is as the following:
> <serial type='pty'>
> <target port='0'/>
> <address type='spapr-vio'/>
> </serial>
>
> There is no console configuration in this file. The dumped xml file
> is as the following:
> <serial type='pty'>
> <source path='/dev/pts/5'/>
> <target port='0'/>
> <alias name='serial0'/>
> <address type='spapr-vio' reg='0x30000000'/>
> </serial>
> <console type='pty' tty='/dev/pts/5'>
> <source path='/dev/pts/5'/>
> <target type='serial' port='0'/>
> <alias name='serial0'/>
> <address type='spapr-vio' reg='0x30000000'/>
> </console>
>
> It shows that the <console> device is the alias of serial device.
> So its address is the same as the serial device. When dectecting
> the conflicts in the qemuAssignSpaprVIOAddress the first console
> and the serial device conflicts because virDomainDeviceInfoIterate()
> still handle these are two different devices, and in the qemuAssignSpaprVIOAddress(),
> it will compare these two devices' addressed. If they have same address,
> it will report address error. Actually, they should have the same address,
> and the error shouldn't be reported.
>
> So this patch is to handle the first console which targetType is serial
> as the alias of serial device to avoid address conflicts error reported.
>
> Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
> ---
> src/conf/domain_conf.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index d8c0969..cddf6ce 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2035,6 +2035,9 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
> return -1;
> }
> for (i = 0; i < def->nconsoles ; i++) {
> + if ((STREQ(def->os.type, "hvm")) && i == 0 &&
> + def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)
> + continue;
> device.data.chr = def->consoles[i];
> if (cb(def, &device, &def->consoles[i]->info, opaque) < 0)
> return -1;
--
Li Zhang
IBM China Linux Technology Centre
12 years, 3 months