Skip to content

Commit b5429d6

Browse files
Paul Durrantliuw
authored andcommitted
libxl: stop using aodev->device_config in libxl__device_pci_add()...
... to hold a pointer to the device. There is already a 'pci' field in 'pci_add_state' so simply use that from the start. This also allows the 'pci' (xen-project#3) argument to be dropped from do_pci_add(). NOTE: This patch also changes the type of the 'pci_domid' field in 'pci_add_state' from 'int' to 'libxl_domid' which is more appropriate given what the field is used for. Signed-off-by: Paul Durrant <[email protected]> Reviewed-by: Oleksandr Andrushchenko <[email protected]> Acked-by: Wei Liu <[email protected]>
1 parent a825ab3 commit b5429d6

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

tools/libs/light/libxl_pci.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ typedef struct pci_add_state {
10741074
libxl__ev_qmp qmp;
10751075
libxl__ev_time timeout;
10761076
libxl_device_pci *pci;
1077-
int pci_domid;
1077+
libxl_domid pci_domid;
10781078
} pci_add_state;
10791079

10801080
static void pci_add_qemu_trad_watch_state_cb(libxl__egc *egc,
@@ -1091,7 +1091,6 @@ static void pci_add_dm_done(libxl__egc *,
10911091

10921092
static void do_pci_add(libxl__egc *egc,
10931093
libxl_domid domid,
1094-
libxl_device_pci *pci,
10951094
pci_add_state *pas)
10961095
{
10971096
STATE_AO_GC(pas->aodev->ao);
@@ -1101,7 +1100,6 @@ static void do_pci_add(libxl__egc *egc,
11011100
/* init pci_add_state */
11021101
libxl__xswait_init(&pas->xswait);
11031102
libxl__ev_qmp_init(&pas->qmp);
1104-
pas->pci = pci;
11051103
pas->pci_domid = domid;
11061104
libxl__ev_time_init(&pas->timeout);
11071105

@@ -1564,13 +1562,10 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t domid,
15641562
int stubdomid = 0;
15651563
pci_add_state *pas;
15661564

1567-
/* Store *pci to be used by callbacks */
1568-
aodev->device_config = pci;
1569-
aodev->device_type = &libxl__pci_devtype;
1570-
15711565
GCNEW(pas);
15721566
pas->aodev = aodev;
15731567
pas->domid = domid;
1568+
pas->pci = pci;
15741569
pas->starting = starting;
15751570
pas->callback = device_pci_add_stubdom_done;
15761571

@@ -1624,9 +1619,10 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t domid,
16241619
GCNEW(pci_s);
16251620
libxl_device_pci_init(pci_s);
16261621
libxl_device_pci_copy(CTX, pci_s, pci);
1622+
pas->pci = pci_s;
16271623
pas->callback = device_pci_add_stubdom_wait;
16281624

1629-
do_pci_add(egc, stubdomid, pci_s, pas); /* must be last */
1625+
do_pci_add(egc, stubdomid, pas); /* must be last */
16301626
return;
16311627
}
16321628

@@ -1681,9 +1677,8 @@ static void device_pci_add_stubdom_done(libxl__egc *egc,
16811677
int i;
16821678

16831679
/* Convenience aliases */
1684-
libxl__ao_device *aodev = pas->aodev;
16851680
libxl_domid domid = pas->domid;
1686-
libxl_device_pci *pci = aodev->device_config;
1681+
libxl_device_pci *pci = pas->pci;
16871682

16881683
if (rc) goto out;
16891684

@@ -1718,7 +1713,7 @@ static void device_pci_add_stubdom_done(libxl__egc *egc,
17181713
pci->vdevfn = orig_vdev;
17191714
}
17201715
pas->callback = device_pci_add_done;
1721-
do_pci_add(egc, domid, pci, pas); /* must be last */
1716+
do_pci_add(egc, domid, pas); /* must be last */
17221717
return;
17231718
}
17241719
}
@@ -1734,7 +1729,7 @@ static void device_pci_add_done(libxl__egc *egc,
17341729
EGC_GC;
17351730
libxl__ao_device *aodev = pas->aodev;
17361731
libxl_domid domid = pas->domid;
1737-
libxl_device_pci *pci = aodev->device_config;
1732+
libxl_device_pci *pci = pas->pci;
17381733

17391734
if (rc) {
17401735
LOGD(ERROR, domid,

0 commit comments

Comments
 (0)