[libvirt] [PATCH v2 05/10] utils: util functions for scsi hostdev

Han Cheng hanc.fnst at cn.fujitsu.com
Wed Apr 3 06:13:15 UTC 2013



On 04/03/2013 01:06 PM, Hu Tao wrote:
> On Mon, Apr 01, 2013 at 08:00:57PM +0800, Han Cheng wrote:
>> +struct _virSCSIDevice {
>> +    unsigned int      adapter;
>> +    unsigned int      bus;
>> +    unsigned int      target;
>> +    unsigned int      unit;
>> +
>> +    char          *name;   /* adapter:bus:target:unit */
>> +    char          *id;     /* model vendor */
>> +    char          *path;
>> +    const char    *used_by;           /* name of the domain using this dev */
>> +
>> +    unsigned int      readonly : 1;
>> +};
>> +
>> +struct _virSCSIDeviceList {
>> +    virObjectLockable parent;
>> +    unsigned int count;
>> +    virSCSIDevicePtr *devs;
>> +};
>
> I think it's better to implement a generic object list, otherwise
> everytime who wants a list, he/she has to re-implement a list.

I agree with you. And I mentioned it in the cover letter.

>> +
>> +static virClassPtr virSCSIDeviceListClass;
>> +
>> +static void virSCSIDeviceListDispose(void *obj);
>> +
>> +static int virSCSIOnceInit(void)
>> +{
>> +    if (!(virSCSIDeviceListClass = virClassNew(virClassForObjectLockable(),
>> +                                              "virSCSIDeviceList",
>> +                                              sizeof(virSCSIDeviceList),
>> +                                              virSCSIDeviceListDispose)))
>
> The indentation style is:
>
>    virClassNew(...
>                ...
>                ^
>
> Please correct them everywhere in your patches.  You want to have a look
> at HACKING for configs of editors.

Sorry about this. This will be fixed.

>> +
>> +int virSCSIDeviceFileIterate(virSCSIDevicePtr dev,
>> +                             virSCSIDeviceFileActor actor,
>> +                             void *opaque)
>> +{
>> +    return (actor)(dev, dev->path, opaque);
>> +}
>
> What's the difference with directly calling actor?

To be honest, I don't know the difference. Maybe there is no difference.
I just define and use it like vir(pci|usb).c




More information about the libvir-list mailing list