Skip to contentSkip to conversation

libxl: Is the nic param to libxl_network_device_add an (in)_out parameter?

DISCUSSION Euan Harris 3 participants 5 messages Nov 18, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

If I call libxl_device_nic_add and pass in a mostly-default libxl_device_nic structure, the function fills in the unspecified default config fields with data for the NIC which it has just created:

	libxl_device_nic nic;
   	libxl_device_nic_init(&nic);
	/* 
	   nic.devid == -1 
	   nic.mac == 00:00:00:00:00:00 
           nic.model == null
	   etc.
	 */

	libxl_device_nic_add(ctx, domid, &nic, NULL);
	/* 
	   nic.devid == 3 
	   nic.mac == 00:16:3e:1b:7b:12
           nic.model == rtl8139
	   etc.
	 */

Is this behaviour an intentional part of the API which I can rely on, or just an artefact of the current implementation? In other words, is nic meant to be an (in)_out parameter? If it's not, what is the correct way to find out the device ID which was allocated for the new device, for example?

Thanks,
Euan

#1 lore raw
Quoted 23 lines · Euan Harris

Hi,

If I call libxl_device_nic_add and pass in a mostly-default libxl_device_nic structure, the function fills in the unspecified default config fields with data for the NIC which it has just created:

	libxl_device_nic nic;
   	libxl_device_nic_init(&nic);
	/* 
	   nic.devid == -1 
	   nic.mac == 00:00:00:00:00:00 
           nic.model == null
	   etc.
	 */

	libxl_device_nic_add(ctx, domid, &nic, NULL);
	/* 
	   nic.devid == 3 
	   nic.mac == 00:16:3e:1b:7b:12
           nic.model == rtl8139
	   etc.
	 */
Quoted 3 lines

Is this behaviour an intentional part of the API which I can rely on, or just an artefact of the current implementation? In other words, is nic meant to be an (in)_out parameter?

I believe so, yes. The comment under "Devices" in libxl.h probably ought to be adjusted to say so explicitly.

Ian (J) -- do you agree?

Quoted 3 lines

If it's not, what is the correct
way to find out the device ID which was allocated for the new device, for example?

You would have to libxl_device_<type>_list and look for it, which is clearly suboptimal.

Ian.

#2 lore raw

Ian Campbell writes ("Re: [Xen-devel] libxl: Is the nic param to libxl_network_device_add an (in)_out parameter?"):

Quoted 4 lines · Euan Harris
Quoted 3 lines

If I call libxl_device_nic_add and pass in a mostly-default libxl_device_nic structure, the function fills in the unspecified default config fields with data for the NIC which it has just created:

...

Quoted 3 lines
Quoted 3 lines

Is this behaviour an intentional part of the API which I can rely on, or just an artefact of the current implementation? In other words, is nic meant to be an (in)_out parameter?

Yes.

Quoted 4 lines

I believe so, yes. The comment under "Devices" in libxl.h probably ought to be adjusted to say so explicitly.

Ian (J) -- do you agree?

I do. I think this applies to other kinds of device too, which might have unspecified parameters which get filled in.

Euan, would you like to send us a doc patch for libxl.h ?

Ian.

#3 lore raw
Quoted 12 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] libxl: Is the nic param to libxl_network_device_add an (in)_out parameter?"):

Quoted 4 lines · Euan Harris
Quoted 3 lines

If I call libxl_device_nic_add and pass in a mostly-default libxl_device_nic structure, the function fills in the unspecified default config fields with data for the NIC which it has just created:

...

Quoted 3 lines
Quoted 3 lines

Is this behaviour an intentional part of the API which I can rely on, or just an artefact of the current implementation? In other words, is nic meant to be an (in)_out parameter?

Yes.

Quoted 7 lines
Quoted 4 lines

I believe so, yes. The comment under "Devices" in libxl.h probably ought to be adjusted to say so explicitly.

Ian (J) -- do you agree?

I do. I think this applies to other kinds of device too, which might have unspecified parameters which get filled in.

Agreed. The docs section I was referring to is generic to all devices, not just nics (i.e. it talks about libxl_device_<type>_add etc), so a comment change would (and should) apply to everything.

Quoted 4 lines

Euan, would you like to send us a doc patch for libxl.h ?

Ian.

#4 lore raw
In reply to Ian Jackson
Quoted 9 lines
Quoted 4 lines

I believe so, yes. The comment under "Devices" in libxl.h probably ought to be adjusted to say so explicitly.

Ian (J) -- do you agree?

I do. I think this applies to other kinds of device too, which might have unspecified parameters which get filled in.

Euan, would you like to send us a doc patch for libxl.h ?

I have sent a patch for the Devices comment. If I come across more
functions which behave similarly I'll send more patches.

Thanks,
Euan