From 898e76f0aac9a9cb200006e4dc1b598934737fb8 Mon Sep 17 00:00:00 2001 From: Luyao Huang Date: Mon, 15 Jun 2015 21:58:36 +0800 Subject: [PATCH] Improve some errors for openconsole/channel Functions like virDomainOpenConsole() and virDomainOpenChannel() accept NULL as a dev_name parameter. Try using alias for the error message if dev_name is not specified. Before: error: internal error: character device is not using a PTY After: error: internal error: character device serial0 is not using a PTY Signed-off-by: Luyao Huang --- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 3 ++- src/qemu/qemu_driver.c | 4 ++-- src/uml/uml_driver.c | 3 ++- src/xen/xen_driver.c | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index a7be74572a..36e4e066ba 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4299,7 +4299,7 @@ libxlDomainOpenConsole(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), - NULLSTR(dev_name)); + dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 31fb47071f..cc1277bddc 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3484,7 +3484,8 @@ lxcDomainOpenConsole(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("character device %s is not using a PTY"), dev_name); + _("character device %s is not using a PTY"), + dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c1373de6ec..1e3caf4a52 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15958,7 +15958,7 @@ qemuDomainOpenConsole(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), - NULLSTR(dev_name)); + dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } @@ -16032,7 +16032,7 @@ qemuDomainOpenChannel(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_UNIX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("channel %s is not using a UNIX socket"), - NULLSTR(name)); + name ? name : NULLSTR(chr->info.alias)); goto cleanup; } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index f09e79b1f3..7a95458119 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2640,7 +2640,8 @@ umlDomainOpenConsole(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("character device %s is not using a PTY"), dev_name); + _("character device %s is not using a PTY"), + dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index da9e6f4e8a..ce31f0f883 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2705,7 +2705,8 @@ xenUnifiedDomainOpenConsole(virDomainPtr dom, if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("character device %s is not using a PTY"), dev_name); + _("character device %s is not using a PTY"), + dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; }