"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote: > With the recent work to support -drive arg, the QEMU driver now supports > many types of bus for disks attached to VMs - ide, scsi, virtio. This patches > adds another type 'xen' for the Xen blkfront driver. ... > diff -r f6b47c9986b9 src/util.c > --- a/src/util.c Sat May 10 12:57:20 2008 -0400 > +++ b/src/util.c Sat May 10 12:57:46 2008 -0400 > @@ -779,23 +779,17 @@ > const char *ptr = NULL; > int idx = 0; > > - if (strlen(name) < 3) > + if (!STRPREFIX(name, "fd") && > + !STRPREFIX(name, "hd") && > + !STRPREFIX(name, "vd") && > + !STRPREFIX(name, "sd") && > + !STRPREFIX(name, "xvd")) > return -1; > > - switch (*name) { > - case 'f': > - case 'h': > - case 'v': > - case 's': > - break; > - default: > - return 0; > - } > - > - if (*(name + 1) != 'd') > - return -1; > - > - ptr = name+2; > + if (STRPREFIX(name, "xvd")) > + ptr = name+3; > + else > + ptr = name+2; Looks fine. The only change I'd be tempted to make would be to iterate over the prefixes, so that the fact "xvd" is a different length isn't handled separately: const char *ptr = NULL; static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd"}; unsigned int i; for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) if (STRPREFIX(name, drive_prefix[i]) { ptr = name + strlen(drive_prefix[i]); break; } if (!ptr) return -1; -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list