Re: [libvirt] [PATCH] qemu: fix block stats for virtio and scsi

2008-10-10 Thread Guido Günther
On Tue, Oct 07, 2008 at 03:03:10PM -0400, Cole Robinson wrote:
> Guido Günther wrote:
> > On Thu, Oct 02, 2008 at 09:06:25PM +0100, Daniel P. Berrange wrote:
> >> I think this needs to use the virDiskNameToIndex() method to
> >> extract the index instead.
> > Corrected pach attached. I don't know how devices are called when using
> > xenner so I left that out.
> >  -- Guido
> > 
> > 
> 
> There is actually a function in qemu_driver.c called
> qemudDiskDeviceName that handles a lot of this already,
> it's used for generating the connect/eject cdrom names.
> It's probably best to reuse that.
Yes this makes sense. After fixing things up a little in
virDiskNameToBusDeviceIndex and qemudDiskDeviceName this works. I'll
post this as 3 tiny patches since they might be helpful on their own and
can be applied in case there's still something wrong with the
blockstats.
 -- Guido

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: fix block stats for virtio and scsi

2008-10-07 Thread Cole Robinson
Guido Günther wrote:
> On Thu, Oct 02, 2008 at 09:06:25PM +0100, Daniel P. Berrange wrote:
>> I think this needs to use the virDiskNameToIndex() method to
>> extract the index instead.
> Corrected pach attached. I don't know how devices are called when using
> xenner so I left that out.
>  -- Guido
> 
> 

There is actually a function in qemu_driver.c called
qemudDiskDeviceName that handles a lot of this already,
it's used for generating the connect/eject cdrom names.
It's probably best to reuse that.

Thanks,
Cole

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: fix block stats for virtio and scsi

2008-10-02 Thread Guido Günther
On Thu, Oct 02, 2008 at 09:06:25PM +0100, Daniel P. Berrange wrote:
> I think this needs to use the virDiskNameToIndex() method to
> extract the index instead.
Corrected pach attached. I don't know how devices are called when using
xenner so I left that out.
 -- Guido
>From c1499445011166aa53bc729e5e6bf1fd55f872ee Mon Sep 17 00:00:00 2001
From: Guido Guenther <[EMAIL PROTECTED]>
Date: Thu, 2 Oct 2008 21:12:20 +0200
Subject: [PATCH] support virtio and scsi disks in qemudDomainBlockStats

---
 src/qemu_driver.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index a1e7285..2155017 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -3416,15 +3416,23 @@ qemudDomainBlockStats (virDomainPtr dom,
  *   hd[a-]   to  ide0-hd[0-]
  *   cdromto  ide1-cd0
  *   fd[a-]   to  floppy[0-]
+ *   vd[a-]   to  virtio[0-]
+ *   sd[a-]   to  scsi0-hd[0-]
  */
 if (STRPREFIX (path, "hd") && c_islower(path[2]))
 snprintf (qemu_dev_name, sizeof (qemu_dev_name),
-  "ide0-hd%d", path[2] - 'a');
+  "ide0-hd%d", virDiskNameToIndex(path));
 else if (STREQ (path, "cdrom"))
 strcpy (qemu_dev_name, "ide1-cd0");
 else if (STRPREFIX (path, "fd") && c_islower(path[2]))
 snprintf (qemu_dev_name, sizeof (qemu_dev_name),
-  "floppy%d", path[2] - 'a');
+  "floppy%d", virDiskNameToIndex(path));
+else if (STRPREFIX (path, "vd") && c_islower(path[2]))
+snprintf (qemu_dev_name, sizeof (qemu_dev_name),
+  "virtio%d", virDiskNameToIndex(path));
+else if (STRPREFIX (path, "sd") && c_islower(path[2]))
+snprintf (qemu_dev_name, sizeof (qemu_dev_name),
+  "scsi0-hd%d", virDiskNameToIndex(path));
 else {
 qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
   _("invalid path: %s"), path);
-- 
1.5.6.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: fix block stats for virtio and scsi

2008-10-02 Thread Daniel P. Berrange
On Thu, Oct 02, 2008 at 09:56:51PM +0200, Guido G?nther wrote:
> Hi,
> qemudDomainBlockStats needs to map between qemu and libvirt device
> naming as well. Possible patch attached.
> Cheers, 
>  -- Guido

> >From 57b8c8e66abfcc57c2f05d8b8364de6ecc05dcf9 Mon Sep 17 00:00:00 2001
> From: Guido Guenther <[EMAIL PROTECTED]>
> Date: Thu, 2 Oct 2008 21:12:20 +0200
> Subject: [PATCH] support virtio and scsi disks in qemudDomainBlockStats
> 
> ---
>  src/qemu_driver.c |8 
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index a1e7285..2a7c555 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -3416,6 +3416,8 @@ qemudDomainBlockStats (virDomainPtr dom,
>   *   hd[a-]   to  ide0-hd[0-]
>   *   cdromto  ide1-cd0
>   *   fd[a-]   to  floppy[0-]
> + *   vd[a-]   to  virtio[0-]
> + *   sd[a-]   to  scsi0-hd[0-]
>   */
>  if (STRPREFIX (path, "hd") && c_islower(path[2]))
>  snprintf (qemu_dev_name, sizeof (qemu_dev_name),
> @@ -3425,6 +3427,12 @@ qemudDomainBlockStats (virDomainPtr dom,
>  else if (STRPREFIX (path, "fd") && c_islower(path[2]))
>  snprintf (qemu_dev_name, sizeof (qemu_dev_name),
>"floppy%d", path[2] - 'a');
> +else if (STRPREFIX (path, "vd") && c_islower(path[2]))
> +snprintf (qemu_dev_name, sizeof (qemu_dev_name),
> +  "virtio%d", path[2] - 'a');
> +else if (STRPREFIX (path, "sd") && c_islower(path[2]))
> +snprintf (qemu_dev_name, sizeof (qemu_dev_name),
> +  "scsi0-hd%d", path[2] - 'a');

This isn't correct - it is assuming only a single letter after
the prefix - while true for IDE & Floppy, it doesn't hold true for
SCSI which can have more than 26 devices, so goes to double letters.
We also need to consider Xen style xvdXX devices for Xenner.

I think this needs to use the virDiskNameToIndex() method to
extract the index instead.


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list