#include <assert.h>
#include <libxl.h>
#include <libxl_event.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "testcase_runner.h"
#include "eventloop_runner.h"
#include "testcase_utils.h"
least the next fd event on a different fd */
for (count = 1; count < 100; count++) {
int rc;
+ int fd;
+ char template[] = "/tmp/xltest-XXXXXX";
printf("\n****** Will cancel after %d events ******\n", count);
- do_domain_suspend(tc, domid);
+ fd = mkstemp(template);
+ if (fd < 0) {
+ perror("mkstemp");
+ break;
+ }
+ do_domain_suspend(tc, domid, fd);
if (wait_until_n(tc, EV_LIBXL_CALLBACK, count, &ev)) {
/* The API call returned before we could cancel it.
It should have returned successfully.
*/
+ close(fd);
printf("libxl_domain_suspend returned %d\n",
ev.u.callback_event.rc);
assert(ev.u.callback_event.rc == 0);
/* The API call's return code should indicate that it was cancelled */
wait_for(tc, EV_LIBXL_CALLBACK, &ev);
+ close(fd);
printf("libxl_domain_suspend returned %d\n",
ev.u.callback_event.rc);
assert(ev.u.callback_event.rc == ERROR_CANCELLED
-#include <fcntl.h>
-#include <libxl.h>
#include <stdlib.h>
#include "testcase_utils.h"
return libxl_domain_create_new(t->ctx, dc, domid_out, &t->ao_how, 0);
}
-int do_domain_suspend(struct test *t, uint32_t domid)
+int do_domain_suspend(struct test *t, uint32_t domid, int fd)
{
- int fd = open("/tmp/suspend", O_RDWR | O_CREAT | O_TRUNC, 0644); /* XXX leaked */
-
t->ao_how.callback = generic_callback;
t->ao_how.u.for_callback = t;
- return libxl_domain_suspend(t->ctx, domid, fd, 0, &t->ao_how);
+ return libxl_domain_suspend(t->ctx, domid, fd, LIBXL_SUSPEND_LIVE, &t->ao_how);
}
char *hdd, char *cdrom);
int do_domain_create(struct test *t, libxl_domain_config * dc,
uint32_t * domid_out);
-int do_domain_suspend(struct test *t, uint32_t domid);
+int do_domain_suspend(struct test *t, uint32_t domid, int fd);
#endif /* __TESTCASE_UTILS */