aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-05-28 10:32:35 +0100
committerGitHub <noreply@github.com>2021-05-28 10:32:35 +0100
commit226e04e322d1c2c5dc88561b5c8e0017cf793733 (patch)
treeca2803dabe297cb82cd980071d8ec06b84d54f09 /samples
parentaaa19498e194368c80f2b12b7f380c911f98d9cc (diff)
downloadlibvfio-user-226e04e322d1c2c5dc88561b5c8e0017cf793733.zip
libvfio-user-226e04e322d1c2c5dc88561b5c8e0017cf793733.tar.gz
libvfio-user-226e04e322d1c2c5dc88561b5c8e0017cf793733.tar.bz2
gpio: optionally disable migration (#536)
This helps debugging. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'samples')
-rw-r--r--samples/gpio-pci-idio-16.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c
index 7bffb5e..d773067 100644
--- a/samples/gpio-pci-idio-16.c
+++ b/samples/gpio-pci-idio-16.c
@@ -142,6 +142,7 @@ main(int argc, char *argv[])
int ret;
bool verbose = false;
bool restart = true;
+ bool enable_migr = true;
int opt;
struct sigaction act = { .sa_handler = _sa_handler };
vfu_ctx_t *vfu_ctx;
@@ -158,7 +159,7 @@ main(int argc, char *argv[])
.write_data = &migration_write_data
};
- while ((opt = getopt(argc, argv, "Rv")) != -1) {
+ while ((opt = getopt(argc, argv, "MRv")) != -1) {
switch (opt) {
case 'R':
restart = false;
@@ -166,6 +167,9 @@ main(int argc, char *argv[])
case 'v':
verbose = true;
break;
+ case 'M':
+ enable_migr = false;
+ break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-Rv] <socketpath>\n", argv[0]);
exit(EXIT_FAILURE);
@@ -210,15 +214,17 @@ main(int argc, char *argv[])
err(EXIT_FAILURE, "failed to setup region");
}
- ret = vfu_setup_region(vfu_ctx, VFU_PCI_DEV_MIGR_REGION_IDX, migr_size,
- NULL, VFU_REGION_FLAG_RW, NULL, 0, -1, 0);
- if (ret < 0) {
- err(EXIT_FAILURE, "failed to setup migration region");
- }
- ret = vfu_setup_device_migration_callbacks(vfu_ctx, &migr_callbacks,
- migr_regs_size);
- if (ret < 0) {
- err(EXIT_FAILURE, "failed to setup device migration");
+ if (enable_migr) {
+ ret = vfu_setup_region(vfu_ctx, VFU_PCI_DEV_MIGR_REGION_IDX, migr_size,
+ NULL, VFU_REGION_FLAG_RW, NULL, 0, -1, 0);
+ if (ret < 0) {
+ err(EXIT_FAILURE, "failed to setup migration region");
+ }
+ ret = vfu_setup_device_migration_callbacks(vfu_ctx, &migr_callbacks,
+ migr_regs_size);
+ if (ret < 0) {
+ err(EXIT_FAILURE, "failed to setup device migration");
+ }
}
ret = vfu_setup_device_nr_irqs(vfu_ctx, VFU_DEV_INTX_IRQ, 1);