diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:28 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:28 +0100 |
commit | 83cc69faaf25b7b629b7c0a9ab70287219b86344 (patch) | |
tree | c433209ca30590188f9076be2edf0a00ca257058 /tools/libxl/libxl_pci.c | |
parent | 34d1cced249c2fe083968b07331baa857db60b4e (diff) | |
download | xen-83cc69faaf25b7b629b7c0a9ab70287219b86344.tar.gz xen-83cc69faaf25b7b629b7c0a9ab70287219b86344.tar.bz2 xen-83cc69faaf25b7b629b7c0a9ab70287219b86344.zip |
libxl: further fixups re LIBXL_DOMAIN_TYPE
* Abolish the macro LIBXL__DOMAIN_IS_TYPE which had incorrect error
handling. At every call site, replace it with an open-coded call to
libxl_domain_type and check against LIBXL_DOMAIN_TYPE_INVALID.
* This involves adding an `out:' to libxl_domain_unpause.
* In libxl_domain_destroy and do_pci_add, do not `default: abort();'
if the domain type cannot be found. Instead switch on
LIBXL_DOMAIN_TYPE_INVALID specifically and do some actual error
handling.
* In libxl__primary_console_find, remove a spurious default clause
from the domain type switch.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_pci.c')
-rw-r--r-- | tools/libxl/libxl_pci.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 28a11afbb0..9c92ae61a5 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -129,7 +129,11 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d if (!num_devs) return libxl__create_pci_backend(gc, domid, pcidev, 1); - if (!starting && LIBXL__DOMAIN_IS_TYPE(gc, domid, PV)) { + libxl_domain_type domtype = libxl__domain_type(gc, domid); + if (domtype == LIBXL_DOMAIN_TYPE_INVALID) + return ERROR_FAIL; + + if (!starting && domtype == LIBXL_DOMAIN_TYPE_PV) { if (libxl__wait_for_backend(gc, be_path, "4") < 0) return ERROR_FAIL; } @@ -172,7 +176,11 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, libx return ERROR_INVAL; num = atoi(num_devs); - if (LIBXL__DOMAIN_IS_TYPE(gc, domid, PV)) { + libxl_domain_type domtype = libxl__domain_type(gc, domid); + if (domtype == LIBXL_DOMAIN_TYPE_INVALID) + return ERROR_FAIL; + + if (domtype == LIBXL_DOMAIN_TYPE_PV) { if (libxl__wait_for_backend(gc, be_path, "4") < 0) { LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path); return ERROR_FAIL; @@ -200,7 +208,7 @@ retry_transaction: if (errno == EAGAIN) goto retry_transaction; - if (LIBXL__DOMAIN_IS_TYPE(gc, domid, PV)) { + if (domtype == LIBXL_DOMAIN_TYPE_PV) { if (libxl__wait_for_backend(gc, be_path, "4") < 0) { LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path); return ERROR_FAIL; @@ -942,8 +950,8 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i } break; } - default: - abort(); + case LIBXL_DOMAIN_TYPE_INVALID: + return ERROR_FAIL; } out: if (!libxl_is_stubdom(ctx, domid, NULL)) { |