0c76f22ef1
- bnc#633573 - System fail to boot after running several warm reboot tests 22749-vtd-workarounds.patch - Upstream patches from Jan 22744-ept-pod-locking.patch 22777-vtd-ats-fixes.patch 22781-pod-hap-logdirty.patch 22782-x86-emul-smsw.patch 22789-i386-no-x2apic.patch 22790-svm-resume-migrate-pirqs.patch 22816-x86-pirq-drop-priv-check.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=94
180 lines
4.6 KiB
Diff
180 lines
4.6 KiB
Diff
Subject: xenpaging: add signal handling
|
|
|
|
Leave paging loop if xenpaging gets a signal.
|
|
Remove paging file on exit.
|
|
|
|
(xen-unstable changeset: 22438:d622cf8c372e)
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
|
|
---
|
|
v2:
|
|
unlink pagefile in signal handler to avoid stale pagefiles if xenpaging is
|
|
stuck in some loop
|
|
|
|
tools/xenpaging/xenpaging.c | 42 +++++++++++++++++++++++++++++++++---------
|
|
1 file changed, 33 insertions(+), 9 deletions(-)
|
|
|
|
Index: xen-4.0.2-testing/tools/xenpaging/xenpaging.c
|
|
===================================================================
|
|
--- xen-4.0.2-testing.orig/tools/xenpaging/xenpaging.c
|
|
+++ xen-4.0.2-testing/tools/xenpaging/xenpaging.c
|
|
@@ -23,6 +23,7 @@
|
|
|
|
#include <inttypes.h>
|
|
#include <stdlib.h>
|
|
+#include <signal.h>
|
|
#include <xc_private.h>
|
|
|
|
#include <xen/mem_event.h>
|
|
@@ -41,6 +42,14 @@
|
|
#define DPRINTF(...) ((void)0)
|
|
#endif
|
|
|
|
+static char filename[80];
|
|
+static int interrupted;
|
|
+static void close_handler(int sig)
|
|
+{
|
|
+ interrupted = sig;
|
|
+ if ( filename[0] )
|
|
+ unlink(filename);
|
|
+}
|
|
|
|
static void *init_page(void)
|
|
{
|
|
@@ -245,7 +254,6 @@ int xenpaging_teardown(xenpaging_t *pagi
|
|
if ( rc != 0 )
|
|
{
|
|
ERROR("Error tearing down domain paging in xen");
|
|
- goto err;
|
|
}
|
|
|
|
/* Unbind VIRQ */
|
|
@@ -253,7 +261,6 @@ int xenpaging_teardown(xenpaging_t *pagi
|
|
if ( rc != 0 )
|
|
{
|
|
ERROR("Error unbinding event port");
|
|
- goto err;
|
|
}
|
|
paging->mem_event.port = -1;
|
|
|
|
@@ -262,7 +269,6 @@ int xenpaging_teardown(xenpaging_t *pagi
|
|
if ( rc != 0 )
|
|
{
|
|
ERROR("Error closing event channel");
|
|
- goto err;
|
|
}
|
|
paging->mem_event.xce_handle = -1;
|
|
|
|
@@ -271,7 +277,6 @@ int xenpaging_teardown(xenpaging_t *pagi
|
|
if ( rc != 0 )
|
|
{
|
|
ERROR("Error closing connection to xen");
|
|
- goto err;
|
|
}
|
|
paging->xc_handle = -1;
|
|
|
|
@@ -376,7 +381,7 @@ int xenpaging_evict_page(xenpaging_t *pa
|
|
return ret;
|
|
}
|
|
|
|
-int xenpaging_resume_page(xenpaging_t *paging, mem_event_response_t *rsp)
|
|
+static int xenpaging_resume_page(xenpaging_t *paging, mem_event_response_t *rsp)
|
|
{
|
|
int ret;
|
|
|
|
@@ -456,6 +461,11 @@ static int evict_victim(xenpaging_t *pag
|
|
goto out;
|
|
}
|
|
|
|
+ if ( interrupted )
|
|
+ {
|
|
+ ret = -EINTR;
|
|
+ goto out;
|
|
+ }
|
|
ret = xc_mem_paging_nominate(paging->xc_handle,
|
|
paging->mem_event.domain_id, victim->gfn);
|
|
if ( ret == 0 )
|
|
@@ -480,6 +490,7 @@ static int evict_victim(xenpaging_t *pag
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
+ struct sigaction act;
|
|
domid_t domain_id;
|
|
int num_pages;
|
|
xenpaging_t *paging;
|
|
@@ -492,7 +503,6 @@ int main(int argc, char *argv[])
|
|
|
|
int open_flags = O_CREAT | O_TRUNC | O_RDWR;
|
|
mode_t open_mode = S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH;
|
|
- char filename[80];
|
|
int fd;
|
|
|
|
if ( argc != 3 )
|
|
@@ -514,7 +524,7 @@ int main(int argc, char *argv[])
|
|
if ( paging == NULL )
|
|
{
|
|
ERROR("Error initialising paging");
|
|
- goto out;
|
|
+ return 1;
|
|
}
|
|
|
|
/* Open file */
|
|
@@ -523,9 +533,18 @@ int main(int argc, char *argv[])
|
|
if ( fd < 0 )
|
|
{
|
|
perror("failed to open file");
|
|
- return -1;
|
|
+ return 2;
|
|
}
|
|
|
|
+ /* ensure that if we get a signal, we'll do cleanup, then exit */
|
|
+ act.sa_handler = close_handler;
|
|
+ act.sa_flags = 0;
|
|
+ sigemptyset(&act.sa_mask);
|
|
+ sigaction(SIGHUP, &act, NULL);
|
|
+ sigaction(SIGTERM, &act, NULL);
|
|
+ sigaction(SIGINT, &act, NULL);
|
|
+ sigaction(SIGALRM, &act, NULL);
|
|
+
|
|
/* Evict pages */
|
|
memset(victims, 0, sizeof(xenpaging_victim_t) * num_pages);
|
|
for ( i = 0; i < num_pages; i++ )
|
|
@@ -533,6 +552,8 @@ int main(int argc, char *argv[])
|
|
rc = evict_victim(paging, domain_id, &victims[i], fd, i);
|
|
if ( rc == -ENOSPC )
|
|
break;
|
|
+ if ( rc == -EINTR )
|
|
+ break;
|
|
if ( i % 100 == 0 )
|
|
DPRINTF("%d pages evicted\n", i);
|
|
}
|
|
@@ -540,7 +561,7 @@ int main(int argc, char *argv[])
|
|
DPRINTF("pages evicted\n");
|
|
|
|
/* Swap pages in and out */
|
|
- while ( 1 )
|
|
+ while ( !interrupted )
|
|
{
|
|
/* Wait for Xen to signal that a page needs paged in */
|
|
rc = xc_wait_for_event_or_timeout(paging->mem_event.xce_handle, 100);
|
|
@@ -631,8 +652,10 @@ int main(int argc, char *argv[])
|
|
}
|
|
}
|
|
}
|
|
+ DPRINTF("xenpaging got signal %d\n", interrupted);
|
|
|
|
out:
|
|
+ close(fd);
|
|
free(victims);
|
|
|
|
/* Tear down domain paging */
|
|
@@ -643,6 +666,7 @@ int main(int argc, char *argv[])
|
|
if ( rc == 0 )
|
|
rc = rc1;
|
|
|
|
+ DPRINTF("xenpaging exit code %d\n", rc);
|
|
return rc;
|
|
}
|
|
|