On Tue, Nov 02, 2010 at 05:49:10PM +0000, Daniel P. Berrange wrote:
This provides an implementation of the virDomainOpenConsole
API with the QEMU driver. For the streams code, this reuses
most of the code previously added for the tunnelled migration
streams since it is generic.
* src/qemu/qemu_driver.c: Support virDomainOpenConsole
---
src/qemu/qemu_driver.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 77 insertions(+), 1 deletions(-)
[...]
+ if (devname) {
+ if (vm->def->console &&
+ STREQ(devname, vm->def->console->info.alias))
+ chr = vm->def->console;
+ for (i = 0 ; !chr && i < vm->def->nserials ; i++) {
+ if (STREQ(devname, vm->def->serials[i]->info.alias))
+ chr = vm->def->serials[i];
small nit, maybe we should break in the loop if found, a priori it
doesn't change the semantic though. Something like a goto found:
when doing the affectation, but this makes the code a bit more
complex...
+ }
+ for (i = 0 ; !chr && i < vm->def->nparallels ; i++) {
+ if (STREQ(devname, vm->def->parallels[i]->info.alias))
+ chr = vm->def->parallels[i];
+ }
+ } else {
+ if (vm->def->console)
+ chr = vm->def->console;
+ else if (vm->def->nserials)
+ chr = vm->def->serials[0];
+ }
the following test could be removed then directly error and goto
cleanup
+ if (!chr) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find character device %s"),
+ NULLSTR(devname));
+ goto cleanup;
+ }
found:
+
+ if (chr->type != VIR_DOMAIN_CHR_TYPE_PTY) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("character device %s is not using a PTY"),
+ NULLSTR(devname));
+ goto cleanup;
+ }
ACK, code is still fine as-is
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/