Commit eb54b6dcb8c6795c3667bcf1cb142639a36fdf85

Authored by Gerd Hoffmann
Committed by Anthony Liguori
1 parent ab73ff29

qdev: add id= support for pci nics.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 3 changed files with 7 additions and 1 deletions
hw/pci.c
@@ -822,6 +822,8 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, @@ -822,6 +822,8 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
822 if (strcmp(nd->model, pci_nic_models[i]) == 0) { 822 if (strcmp(nd->model, pci_nic_models[i]) == 0) {
823 pci_dev = pci_create(pci_nic_names[i], devaddr); 823 pci_dev = pci_create(pci_nic_names[i], devaddr);
824 dev = &pci_dev->qdev; 824 dev = &pci_dev->qdev;
  825 + if (nd->id)
  826 + dev->id = qemu_strdup(nd->id);
825 dev->nd = nd; 827 dev->nd = nd;
826 qdev_init(dev); 828 qdev_init(dev);
827 nd->private = dev; 829 nd->private = dev;
@@ -2428,7 +2428,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p) @@ -2428,7 +2428,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
2428 } 2428 }
2429 if (!strcmp(device, "nic")) { 2429 if (!strcmp(device, "nic")) {
2430 static const char * const nic_params[] = { 2430 static const char * const nic_params[] = {
2431 - "vlan", "name", "macaddr", "model", "addr", "vectors", NULL 2431 + "vlan", "name", "macaddr", "model", "addr", "id", "vectors", NULL
2432 }; 2432 };
2433 NICInfo *nd; 2433 NICInfo *nd;
2434 uint8_t *macaddr; 2434 uint8_t *macaddr;
@@ -2466,6 +2466,9 @@ int net_client_init(Monitor *mon, const char *device, const char *p) @@ -2466,6 +2466,9 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
2466 if (get_param_value(buf, sizeof(buf), "addr", p)) { 2466 if (get_param_value(buf, sizeof(buf), "addr", p)) {
2467 nd->devaddr = strdup(buf); 2467 nd->devaddr = strdup(buf);
2468 } 2468 }
  2469 + if (get_param_value(buf, sizeof(buf), "id", p)) {
  2470 + nd->id = strdup(buf);
  2471 + }
2469 nd->nvectors = NIC_NVECTORS_UNSPECIFIED; 2472 nd->nvectors = NIC_NVECTORS_UNSPECIFIED;
2470 if (get_param_value(buf, sizeof(buf), "vectors", p)) { 2473 if (get_param_value(buf, sizeof(buf), "vectors", p)) {
2471 char *endptr; 2474 char *endptr;
@@ -95,6 +95,7 @@ struct NICInfo { @@ -95,6 +95,7 @@ struct NICInfo {
95 const char *model; 95 const char *model;
96 const char *name; 96 const char *name;
97 const char *devaddr; 97 const char *devaddr;
  98 + const char *id;
98 VLANState *vlan; 99 VLANState *vlan;
99 VLANClientState *vc; 100 VLANClientState *vc;
100 void *private; 101 void *private;