9621add6e3
support qcow2, so blktap is needed to support domains with 'tap:qcow2' disk configurations. modified tmp-initscript-modprobe.patch - bnc#809203 - xen.efi isn't signed with SUSE Secure Boot key xen.spec - Fix adding managed PCI device to an inactive domain modified xen-managed-pci-device.patch - bnc#805094 - xen hot plug attach/detach fails modified blktap-pv-cdrom.patch - bnc# 802690 - domain locking can prevent a live migration from completing modified xend-domain-lock.patch - bnc#797014 - no way to control live migrations 26675-tools-xentoollog_update_tty_detection_in_stdiostream_progress.patch xen.migrate.tools-xc_print_messages_from_xc_save_with_xc_report.patch xen.migrate.tools-xc_document_printf_calls_in_xc_restore.patch xen.migrate.tools-xc_rework_xc_save.cswitch_qemu_logdirty.patch xen.migrate.tools_set_migration_constraints_from_cmdline.patch xen.migrate.tools_add_xm_migrate_--log_progress_option.patch - Upstream patches from Jan 26585-x86-mm-Take-the-p2m-lock-even-in-shadow-mode.patch 26595-x86-nhvm-properly-clean-up-after-failure-to-set-up-all-vCPU-s.patch 26601-honor-ACPI-v4-FADT-flags.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=232
137 lines
4.1 KiB
Diff
137 lines
4.1 KiB
Diff
user: Olaf Hering <olaf@aepfle.de>
|
|
date: Wed Mar 06 17:05:10 2013 +0100
|
|
files: tools/xcutils/xc_save.c
|
|
description:
|
|
tools/xc: rework xc_save.c:switch_qemu_logdirty
|
|
|
|
Rework code in switch_qemu_logdirty, fix also memleak.
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
|
|
|
|
diff -r 49b90990442a -r 1ea501d60264 tools/xcutils/xc_save.c
|
|
--- a/tools/xcutils/xc_save.c
|
|
+++ b/tools/xcutils/xc_save.c
|
|
@@ -7,6 +7,7 @@
|
|
*
|
|
*/
|
|
|
|
+#define _GNU_SOURCE
|
|
#include <unistd.h>
|
|
#include <err.h>
|
|
#include <stdlib.h>
|
|
@@ -109,8 +110,10 @@ static int switch_qemu_logdirty(int domi
|
|
{
|
|
xc_interface *xch = si.xch;
|
|
struct xs_handle *xs;
|
|
- char *path, *p, *ret_str, *cmd_str, **watch;
|
|
+ char *path, *dir_p, *ret_str, **watch;
|
|
+ const char *cmd_str;
|
|
unsigned int len;
|
|
+ int ret, again;
|
|
struct timeval tv;
|
|
fd_set fdset;
|
|
|
|
@@ -118,65 +121,56 @@ static int switch_qemu_logdirty(int domi
|
|
PERROR("Couldn't contact xenstore");
|
|
exit(1);
|
|
}
|
|
- if (!(path = strdup("/local/domain/0/device-model/"))) {
|
|
- PERROR("can't get domain path in store");
|
|
+
|
|
+ ret = asprintf(&path, "/local/domain/0/device-model/%i/logdirty/ret", domid);
|
|
+ if (ret < 0) {
|
|
+ ERROR("Couldn't construct xenstore path");
|
|
exit(1);
|
|
}
|
|
- if (!(path = realloc(path, strlen(path)
|
|
- + 10
|
|
- + strlen("/logdirty/cmd") + 1))) {
|
|
- PERROR("no memory for constructing xenstore path");
|
|
- exit(1);
|
|
- }
|
|
- snprintf(path + strlen(path), 11, "%i", domid);
|
|
- strcat(path, "/logdirty/");
|
|
- p = path + strlen(path);
|
|
-
|
|
+ /* Pointer to directory */
|
|
+ dir_p = path + ret - 3;
|
|
|
|
/* Watch for qemu's return value */
|
|
- strcpy(p, "ret");
|
|
- if (!xs_watch(xs, path, "qemu-logdirty-ret"))
|
|
- {
|
|
- ERROR("can't set watch in store (%s)\n", path);
|
|
+ if (!xs_watch(xs, path, "qemu-logdirty-ret")) {
|
|
+ PERROR("can't set watch in store (%s)", path);
|
|
exit(1);
|
|
}
|
|
|
|
- if (!(cmd_str = strdup( enable == 0 ? "disable" : "enable"))) {
|
|
- PERROR("can't get logdirty cmd path in store");
|
|
+ cmd_str = enable ? "enable" : "disable";
|
|
+
|
|
+ /* Tell qemu that we want it to start logging dirty pages to Xen */
|
|
+ strcpy(dir_p, "cmd");
|
|
+ if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) {
|
|
+ PERROR("can't write to store path (%s)", path);
|
|
exit(1);
|
|
}
|
|
|
|
- /* Tell qemu that we want it to start logging dirty page to Xen */
|
|
- strcpy(p, "cmd");
|
|
- if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) {
|
|
- PERROR("can't write to store path (%s)\n", path);
|
|
- exit(1);
|
|
- }
|
|
+ /* Restore initial path */
|
|
+ strcpy(dir_p, "ret");
|
|
+ /* Wait a while for qemu to signal that it has serviced logdirty command */
|
|
+ do {
|
|
+ tv.tv_sec = 5;
|
|
+ tv.tv_usec = 0;
|
|
+ FD_ZERO(&fdset);
|
|
+ FD_SET(xs_fileno(xs), &fdset);
|
|
+ errno = 0;
|
|
|
|
- /* Wait a while for qemu to signal that it has service logdirty command */
|
|
- read_again:
|
|
- tv.tv_sec = 5;
|
|
- tv.tv_usec = 0;
|
|
- FD_ZERO(&fdset);
|
|
- FD_SET(xs_fileno(xs), &fdset);
|
|
-
|
|
- if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) {
|
|
- PERROR("timed out waiting for qemu logdirty response.\n");
|
|
- exit(1);
|
|
- }
|
|
-
|
|
- watch = xs_read_watch(xs, &len);
|
|
- free(watch);
|
|
-
|
|
- strcpy(p, "ret");
|
|
- ret_str = xs_read(xs, XBT_NULL, path, &len);
|
|
- if (ret_str == NULL || strcmp(ret_str, cmd_str))
|
|
+ if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) {
|
|
+ PERROR("timed out waiting for qemu logdirty response.");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
+ watch = xs_read_watch(xs, &len);
|
|
+ free(watch);
|
|
+
|
|
+ ret_str = xs_read(xs, XBT_NULL, path, &len);
|
|
+ again = ret_str == NULL || strcmp(ret_str, cmd_str);
|
|
+ WPRINTF("Got '%s' from logdirty%s.\n", ret_str, again ? ", retrying" : "");
|
|
+ free(ret_str);
|
|
/* Watch fired but value is not yet right */
|
|
- goto read_again;
|
|
+ } while (again);
|
|
|
|
free(path);
|
|
- free(cmd_str);
|
|
- free(ret_str);
|
|
|
|
return 0;
|
|
}
|