[libvirt] [PATCH] qemu_migration: Move waiting for SPICE migration
by Michal Privoznik
Currently, we wait for SPICE to migrate in the very same loop where we
wait for qemu to migrate. This has a disadvantage of slowing seamless
migration down. One one hand, we should not kill the domain until all
SPICE data has been migrated. On the other hand, there is no need to
wait in the very same loop and hence slowing down 'cont' on the
destination. For instance, if users are watching a movie, they can
experience the movie to be stopped for a couple of seconds, as
processors are not running nor on src nor on dst as libvirt waits for
SPICE to migrate. We should move the waiting phase to migration CONFIRM
phase.
---
src/qemu/qemu_migration.c | 57 ++++++++++++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index ca79bc2..1d65df5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1582,6 +1582,40 @@ cleanup:
return ret;
}
+static int
+qemuMigrationWaitForSpice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ bool wait_for_spice = false;
+ bool spice_migrated = false;
+
+ if (vm->def->ngraphics == 1 &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION))
+ wait_for_spice = true;
+
+ if (!wait_for_spice)
+ return 0;
+
+ while (!spice_migrated) {
+ /* Poll every 50ms for progress & to allow cancellation */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 50 * 1000 * 1000ull };
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ if (qemuMonitorGetSpiceMigrationStatus(priv->mon,
+ &spice_migrated) < 0) {
+ qemuDomainObjExitMonitor(driver, vm);
+ return -1;
+ }
+ qemuDomainObjExitMonitor(driver, vm);
+ virObjectUnlock(vm);
+ nanosleep(&ts, NULL);
+ virObjectLock(vm);
+ }
+
+ return 0;
+}
static int
qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
@@ -1591,19 +1625,10 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret;
- bool wait_for_spice = false;
- bool spice_migrated = false;
qemuMonitorMigrationStatus status;
memset(&status, 0, sizeof(status));
- /* If guest uses SPICE and supports seamles_migration we have to hold up
- * migration finish until SPICE server transfers its data */
- if (vm->def->ngraphics == 1 &&
- vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
- virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION))
- wait_for_spice = true;
-
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob);
if (ret < 0) {
/* Guest already exited; nothing further to update. */
@@ -1611,13 +1636,6 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
}
ret = qemuMonitorGetMigrationStatus(priv->mon, &status);
- /* If qemu says migrated, check spice */
- if (wait_for_spice &&
- ret == 0 &&
- status.status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED)
- ret = qemuMonitorGetSpiceMigrationStatus(priv->mon,
- &spice_migrated);
-
qemuDomainObjExitMonitor(driver, vm);
priv->job.status = status;
@@ -1657,8 +1675,7 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
break;
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
- if ((wait_for_spice && spice_migrated) || (!wait_for_spice))
- priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
+ priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
ret = 0;
break;
@@ -4121,6 +4138,10 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
* domain object, but if no, resume CPUs
*/
if (retcode == 0) {
+ /* If guest uses SPICE and supports seamless migration we have to hold
+ * up domain shutdown until SPICE server transfers its data */
+ qemuMigrationWaitForSpice(driver, vm);
+
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "migrated");
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH 0/6] Enumerate scsi generic device
by Osier Yang
The scsi generic device is listed as a child of the parent
of the mapped disk device. E.g.
+- pci_0000_00_1f_2
| |
| +- scsi_host0
| | |
| | +- scsi_target0_0_0
| | |
| | +- scsi_0_0_0_0
| | |
| | +- block_sda_TOSHIBA_MK5061GSY_9243PG8CT
| | +- scsi_generic_sg0
This is consistent with the sysfs/udev.
The XML produced by udev backend:
<device>
<name>scsi_generic_sg0</name>
<path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/scsi_generic/sg0</path>
<parent>scsi_0_0_0_0</parent>
<capability type='scsi_generic'>
<char>/dev/sg0</char>
</capability>
</device>
The XML produced by HAL backend:
<device>
<name>pci_8086_2922_scsi_host_scsi_device_lun0_scsi_generic</name>
<path>/sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/scsi_generic/sg0</path>
<parent>pci_8086_2922_scsi_host_scsi_device_lun0</parent>
<capability type='scsi_generic'>
<char>/dev/sg0</char>
</capability>
</device>
Osier Yang (6):
nodedev: Expose sysfs path of device
nodedev_udev: Refactor udevGetDeviceType
nodedev_udev: Enumerate scsi generic device
nodedev_hal: Enumerate scsi generic device
nodedev: Support SCSI_GENERIC cap flag for listAllNodeDevices
virsh: Support SCSI_GENERIC cap flag for nodedev-list
include/libvirt/libvirt.h.in | 1 +
src/conf/node_device_conf.c | 11 ++-
src/conf/node_device_conf.h | 8 ++-
src/node_device/node_device_hal.c | 9 +++
src/node_device/node_device_udev.c | 137 ++++++++++++++++++++-----------------
tools/virsh-nodedev.c | 3 +
tools/virsh.pod | 6 +-
7 files changed, 105 insertions(+), 70 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] a problem about the progress's display of migration with non-shared storage
by Liuji (Jeremy)
Hi all,
I found a problem about the progress's display of migration with non-shared storage.
In the commit: 7b7600b3e6734117b3db39ba5c31ae33a40fb5bb (qemu_migration: Introduce qemuMigrationDriveMirror),
it use drive mirror instead of block migration. And after the driver mirror, then process the VM migration(no block).
But only in the VM migration stage, libvirt set the progress of migration(in qemuMigrationWaitForCompletion).
In the drive mirror stage, libvirt is waiting the completion of drive mirror, and don't set the progress of migration.
So, the libvirt can't display the progress of migration in the drive mirror stage.
For users, they are not concerned about the implementation details of the two stages. They think the two stages are both migration.
So, I think libvirt need consider the progress of drive mirror for migration. But I don't have a good solution.
Any idea about this problem?
Thanks for advance
Regards
11 years, 4 months
[libvirt] [PATCH 0/6] Support to use iscsi storage in domain conf
by Osier Yang
This supports to use libvirt iscsi storage volume for qemu with
either the LUN's path on host (e.g. /dev/disk/by-path/*-lun-1),
or the the libiscsi uri (e.g iscsi://demo.org:6000/$iqn/1)in
domain conf.
Osier Yang (6):
storage_iscsi: Reflect the default target port
conf: Introduce new XML tag "mode" for disk source
qemu: Translate the iscsi pool/volume disk source
security: Ignore to manage the volume type disk if its mode is uri
conf: Ignore the volume type disk if its mode is "uri"
qemu: Translate the volume type disk source before cgroup setting
docs/formatdomain.html.in | 9 ++-
docs/schemas/domaincommon.rng | 8 +++
src/conf/domain_conf.c | 71 +++++++++++++++++++++-
src/conf/domain_conf.h | 25 ++++++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 20 ++++--
src/qemu/qemu_conf.c | 117 +++++++++++++++++++++++++++++-------
src/qemu/qemu_process.c | 13 ++--
src/security/security_apparmor.c | 10 ++-
src/security/security_dac.c | 10 ++-
src/security/security_selinux.c | 10 ++-
src/storage/storage_backend_iscsi.c | 6 +-
tests/qemuxml2xmltest.c | 1 +
13 files changed, 261 insertions(+), 40 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] Move virGetUserEnt() to where its needed
by Doug Goldstein
In the first if case, virGetUserEnt() isn't necessary so don't bother
calling it before determining we need it.
---
Found this trying to get libvirtd running happily on my Mac OS X machine
for qemu. Unfortunately it appears virGetUserEnt() is always failing
on Mac OS X (getpwuid_r() returns 0 each time) because we are requesting
info on a different high value UIDs each time (32xxx). That's another
issue entirely but this fix allows me to ignore that and test other
fixes on my Mac.
---
src/util/virutil.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index c5246bc..6fa0212e 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -759,12 +759,13 @@ static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
{
const char *path = getenv(xdgenvname);
char *ret = NULL;
- char *home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
+ char *home = NULL;
if (path && path[0]) {
if (virAsprintf(&ret, "%s/libvirt", path) < 0)
goto no_memory;
} else {
+ home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
if (virAsprintf(&ret, "%s/%s/libvirt", home, xdgdefdir) < 0)
goto no_memory;
}
--
1.8.1.5
11 years, 4 months
[libvirt] Unable to setup qemu-guest-agent
by Nehal J. Wani
Could anyone please list out the steps required to run the command
$virsh qemu-agent-command
Steps that I followed:
1. Clone the latest source code of libvirt
2. Create a vm of f18 (source:liveCD)
3. Edit f18 domain xml and add this:
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
4. On host: #./tools/virsh start f18
5. On guest: #yum install qemu-guest-agent -y
6. On host: # ./tools/virsh qemu-agent-command f18
'{"execute":"guest-network-get-interfaces"}'
Expected Response:
{"return":[{"name":"lo","ip-
addresses":[{"ip-address-type":"ipv4","ip-address":"127.0.0.1","prefix":8},{"ip-address-type":"ipv6","ip-address":"::1","prefix":128}],"hardware-address":"00:00:00:00:00:00"},{"name":"eth0","ip-addresses":[{"ip-address-type":"ipv4","ip-address":"192.168.122.62","prefix":24},{"ip-address-type":"ipv6","ip-address":"fe80::5054:ff:fe14:9998","prefix":64}],"hardware-address":"52:54:00:14:99:98"}]}
Actual result:
error: unknown procedure: 3
Where am I going wrong?
--
Nehal J. Wani
UG2, BTech CS+MS(CL)
IIIT-Hyderabad
http://commanlinewani.blogspot.com
11 years, 4 months
[libvirt] [PATCH 0/2] Support setting the 'removable' flag for USB disks
by Fred A. Kemp
From: "Fred A. Kemp" <anonym(a)lavabit.com>
For reference, my first attempt at a patch for this feature was:
<1363682454-32012-1-git-send-email-anonym(a)lavabit.com>
I believe this patch fixes all previous concerns raised that
thread. However, note that I've only added the new capability for
usb-storage.removable to the qemu help tests of qemu(-kvm) version
1.2.0, since that's what I had easily available to get the output of
`-device usb-storage,?` from.
Fred A. Kemp (2):
qemu: Add capability flag for usb-storage
qemu: Support setting the 'removable' flag for USB disks
docs/formatdomain.html.in | 8 +++--
docs/schemas/domaincommon.rng | 8 +++++
src/conf/domain_conf.c | 31 ++++++++++++++++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 10 +++++++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 23 +++++++++++++--
tests/qemuhelpdata/qemu-1.2.0-device | 11 +++++++
tests/qemuhelpdata/qemu-kvm-1.2.0-device | 11 +++++++
tests/qemuhelptest.c | 20 +++++++++----
.../qemuxml2argv-disk-usb-device-removable.args | 8 +++++
.../qemuxml2argv-disk-usb-device-removable.xml | 27 +++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++-
13 files changed, 151 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.xml
--
1.7.10.4
11 years, 4 months
[libvirt] [RFC] conf: Order of AddImplicitControllers and DomainDefPostParse
by Viktor Mihajlovski
Implicit controllers may be dependent on device definitions altered
in a post-parse callback. E.g., if a console device is
defined without the target type, the type will be set in QEMU's
callback. In the case of s390, this is virtio, which requires
an implicit virtio-serial controller.
By moving the implicit controller definition after the post-parse
procssing this can be fixed. OTOH the implicit controllers might
need post-parse actions as well, although I am currentyl not
aware of one.
What would speak against swapping the order as suggested in
the patch below? Feedback welcome.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 8 ++++----
.../qemuxml2xmlout-balloon-device-auto.xml | 2 +-
.../qemuxml2xmlout-channel-virtio-auto.xml | 2 +-
.../qemuxml2xmlout-console-virtio.xml | 2 +-
.../qemuxml2xmlout-disk-scsi-device-auto.xml | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 29d6edc..ef1f876 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12062,14 +12062,14 @@ virDomainDefParseXML(xmlDocPtr xml,
(def->ns.parse)(xml, root, ctxt, &def->namespaceData) < 0)
goto error;
- /* Auto-add any implied controllers which aren't present */
- if (virDomainDefAddImplicitControllers(def) < 0)
- goto error;
-
/* callback to fill driver specific domain aspects */
if (virDomainDefPostParse(def, caps, xmlopt) < 0)
goto error;
+ /* Auto-add any implied controllers which aren't present */
+ if (virDomainDefAddImplicitControllers(def) < 0)
+ goto error;
+
virHashFree(bootHash);
return def;
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
index 6aed326..380b70f 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
@@ -20,8 +20,8 @@
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
- <controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'/>
<memballoon model='virtio'/>
</devices>
</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
index 0175272..fd6b852 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
@@ -25,8 +25,8 @@
<controller type='virtio-serial' index='1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</controller>
- <controller type='virtio-serial' index='2'/>
<controller type='pci' index='0' model='pci-root'/>
+ <controller type='virtio-serial' index='2'/>
<channel type='pty'>
<target type='virtio' name='org.linux-kvm.port.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
index 3c865c3..340430e 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
@@ -21,8 +21,8 @@
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
- <controller type='virtio-serial' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
+ <controller type='virtio-serial' index='0'/>
<console type='pty'>
<target type='virtio' port='0'/>
</console>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
index 7d152bc..5ec1e94 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
@@ -26,8 +26,8 @@
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
- <controller type='scsi' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
+ <controller type='scsi' index='0'/>
<memballoon model='virtio'/>
</devices>
</domain>
--
1.7.9.5
11 years, 4 months
[libvirt] libvirtd 1.0.6 refuses to start
by Franky Van Liedekerke
I just downloaded and compiled libvirtd on the same server as I did
1.0.4. Upon updating, libvirtd refuses to start, with this in the
logfile (obfuscated the hostname by xxx's):
2013-06-11 13:43:49.154+0000: 3336: info : libvirt version: 1.0.6,
package: 1.el6 (Unknown, 2013-06-06-14:57:07, xxxxxxxx)
2013-06-11 13:43:49.154+0000: 3336: error : virFileReadAll:1195 :
Failed to open file '/sys/class/fc_host//host0/max_npiv_vports': No such
file or directory
2013-06-11 13:43:49.159+0000: 3336: error : detect_scsi_host_caps:87 :
Failed to read max_npiv_vports for host1
2013-06-11 13:43:49.163+0000: 3336: error : virFileReadAll:1195 :
Failed to open file '/sys/class/fc_host//host0/max_npiv_vports': No such
file or directory
2013-06-11 13:43:49.163+0000: 3336: error : detect_scsi_host_caps:87 :
Failed to read max_npiv_vports for host2
2013-06-11 13:43:49.386+0000: 3336: error : virLockManagerPluginNew:175
: Failed to load plugin /usr/lib64/libvirt/lock-driver/lockd.so:
/usr/lib64/libvirt/lock-driver/lockd.so: undefined symbol:
virProcessGetStartTime
2013-06-11 13:43:49.386+0000: 3336: error : virStateInitialize:831 :
Initialization of QEMU state driver failed
2013-06-11 13:43:49.386+0000: 3336: error : daemonRunStateInit:887 :
Driver state initialization failed
So it seems two issues are present here:
1) it searches for /sys/class/fc_host//host0/max_npiv_vports for both
host1 and host2. Imho this path needs to be
/sys/class/fc_host//host1/max_npiv_vports and
/sys/class/fc_host//host2/max_npiv_vports respectively.
2) the undefined symbol problem: seems a linking issue, no? The build
worked just fine on rhel6 with all patches applied.
For now I reverted back to 1.0.4. Hope this helps to debug :-)
Also: I created a bug report for 1.0.4/1.0.6 concerning the init
scripts:
https://bugzilla.redhat.com/show_bug.cgi?id=971408
Part of it (the virtlock socket) seems to be in the latest code
already, but I believe the other issues mentioned are valid as well.
With friendly regards,
Franky
11 years, 4 months
[libvirt] [PATCH v2] udev: fix crash in libudev logging
by Ján Tomko
Call virLogVMessage instead of virLogMessage, since libudev
called us with a va_list object, not a list of arguments.
Honor message priority and strip the trailing newline.
https://bugzilla.redhat.com/show_bug.cgi?id=969152
---
v1: https://www.redhat.com/archives/libvir-list/2013-June/msg00349.html
v2: don't ignore priority and strip the trailing newline.
src/libvirt_private.syms | 2 ++
src/node_device/node_device_udev.c | 42 ++++++++++++++++++++++++++++++--------
src/util/virlog.c | 25 +++++++++++++++++++++++
src/util/virlog.h | 1 +
4 files changed, 61 insertions(+), 9 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 042081f..ee517c1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1480,12 +1480,14 @@ virLogMessage;
virLogParseDefaultPriority;
virLogParseFilters;
virLogParseOutputs;
+virLogPriorityFromSyslog;
virLogProbablyLogMessage;
virLogReset;
virLogSetBufferSize;
virLogSetDefaultPriority;
virLogSetFromEnv;
virLogUnlock;
+virLogVMessage;
# util/virmacaddr.h
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 620cd58..b462549 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -348,15 +348,38 @@ static int udevGenerateDeviceName(struct udev_device *device,
}
-static void udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
- int priority ATTRIBUTE_UNUSED,
- const char *file,
- int line,
- const char *fn,
- const char *fmt,
- va_list args)
+typedef void (*udevLogFunctionPtr)(struct udev *udev,
+ int priority,
+ const char *file,
+ int line,
+ const char *fn,
+ const char *format,
+ va_list args);
+
+static void
+ATTRIBUTE_FMT_PRINTF(6,0)
+udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
+ int priority,
+ const char *file,
+ int line,
+ const char *fn,
+ const char *fmt,
+ va_list args)
{
- VIR_ERROR_INT(VIR_LOG_FROM_LIBRARY, file, line, fn, fmt, args);
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ const char *format = NULL;
+
+ virBufferAdd(&buf, fmt, -1);
+ virBufferTrim(&buf, "\n", -1);
+
+ format = virBufferContentAndReset(&buf);
+
+ if (format)
+ virLogVMessage(VIR_LOG_FROM_LIBRARY,
+ virLogPriorityFromSyslog(priority),
+ file, line, fn, NULL, format, args);
+
+ VIR_FREE(format);
}
@@ -1672,7 +1695,8 @@ static int nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
* its return value.
*/
udev = udev_new();
- udev_set_log_fn(udev, udevLogFunction);
+ /* cast to get rid of missing-format-attribute warning */
+ udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (priv->udev_monitor == NULL) {
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 739a274..064f8e8 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1264,6 +1264,31 @@ static int virLogAddOutputToJournald(int priority)
return 0;
}
# endif /* USE_JOURNALD */
+
+int virLogPriorityFromSyslog(int priority)
+{
+ switch (priority) {
+ case LOG_EMERG:
+ case LOG_ALERT:
+ case LOG_CRIT:
+ case LOG_ERR:
+ return VIR_LOG_ERROR;
+ case LOG_WARNING:
+ case LOG_NOTICE:
+ return VIR_LOG_WARN;
+ case LOG_INFO:
+ return VIR_LOG_INFO;
+ case LOG_DEBUG:
+ return VIR_LOG_DEBUG;
+ }
+ return VIR_LOG_ERROR;
+}
+
+#else /* HAVE_SYSLOG_H */
+int virLogPriorityFromSyslog(int priority ATTRIBUTE_UNUSED)
+{
+ return VIR_LOG_ERROR;
+}
#endif /* HAVE_SYSLOG_H */
#define IS_SPACE(cur) \
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 6b83245..7db1657 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -171,6 +171,7 @@ extern int virLogReset(void);
extern int virLogParseDefaultPriority(const char *priority);
extern int virLogParseFilters(const char *filters);
extern int virLogParseOutputs(const char *output);
+extern int virLogPriorityFromSyslog(int priority);
extern void virLogMessage(virLogSource src,
virLogPriority priority,
const char *filename,
--
1.8.1.5
11 years, 4 months