diff options
author | swapnili <swapnil.ingle@nutanix.com> | 2020-12-08 16:01:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 16:01:35 +0100 |
commit | 2015453378f9d00fe271faf0f4cfa39f5f53536a (patch) | |
tree | e655a6837f76e0188cc048c28b4188813ba7ddee /samples | |
parent | 486cb8a724e3259220d1da2ad673118eecb5c360 (diff) | |
download | libvfio-user-2015453378f9d00fe271faf0f4cfa39f5f53536a.zip libvfio-user-2015453378f9d00fe271faf0f4cfa39f5f53536a.tar.gz libvfio-user-2015453378f9d00fe271faf0f4cfa39f5f53536a.tar.bz2 |
Misc fixes for vfu_ctx_try_attach() and vfu_realize_ctx() (#175)
Misc changes for vfu_ctx_try_attach()
* Rename to vfu_attach_ctx()
* Removed call to vfu_realize_ctx(), should be called separately
* Now vfu_attach_ctx() must also be called for blocking ctx.
Misc changes for vfu_realize_ctx()
* Made calling vfu_realize_ctx() mandatory
* vfu_ctx_drive() and vfu_poll_ctx() returns EINVAL if the device is not
realized.
* Renamed vfu_ctx->ready to vfu_ctx->realized
Added unit test for vfu_attach_ctx() and vfu_realize_ctx()
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/gpio-pci-idio-16.c | 10 | ||||
-rw-r--r-- | samples/null.c | 10 | ||||
-rw-r--r-- | samples/server.c | 10 |
3 files changed, 30 insertions, 0 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index e786d43..a957117 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -133,6 +133,16 @@ main(int argc, char *argv[]) err(EXIT_FAILURE, "failed to setup irq counts"); } + ret = vfu_realize_ctx(vfu_ctx); + if (ret < 0) { + err(EXIT_FAILURE, "failed to realize device"); + } + + ret = vfu_attach_ctx(vfu_ctx); + if (ret < 0) { + err(EXIT_FAILURE, "failed to attach device"); + } + ret = vfu_ctx_drive(vfu_ctx); if (ret != 0) { if (ret != -ENOTCONN && ret != -EINTR) { diff --git a/samples/null.c b/samples/null.c index fda260e..7944e30 100644 --- a/samples/null.c +++ b/samples/null.c @@ -62,6 +62,16 @@ static void* null_drive(void *arg) fprintf(stderr, "failed to enable cancel type: %s\n", strerror(ret)); return NULL; } + ret = vfu_realize_ctx(vfu_ctx); + if (ret < 0) { + fprintf(stderr, "failed to realize device\n"); + return NULL; + } + ret = vfu_attach_ctx(vfu_ctx); + if (ret < 0) { + fprintf(stderr, "failed to attach device\n"); + return NULL; + } printf("starting device emulation\n"); vfu_ctx_drive(vfu_ctx); return NULL; diff --git a/samples/server.c b/samples/server.c index 25bf101..be3c4d9 100644 --- a/samples/server.c +++ b/samples/server.c @@ -485,6 +485,16 @@ int main(int argc, char *argv[]) err(EXIT_FAILURE, "failed to allocate migration data"); } + ret = vfu_realize_ctx(vfu_ctx); + if (ret < 0) { + err(EXIT_FAILURE, "failed to realize device"); + } + + ret = vfu_attach_ctx(vfu_ctx); + if (ret < 0) { + err(EXIT_FAILURE, "failed to attach device"); + } + do { ret = vfu_ctx_drive(vfu_ctx); if (ret == -EINTR) { |