Skip to contentSkip to conversation

pci-attach: fix assertation

PATCH Applied Chunyan Liu 4 participants 6 messages Sep 16, 2015 – Sep 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci-attach: fix assertation

Run "xl pci-attach <domain> <pci_device>", the 2nd time fails:
xl: libxl_xshelp.c:209: libxl__xs_transaction_start: Assertion `!*t' failed. Aborted

To fix that, initialize xs_transaction to avoid libxl__xs_transaction_start assertation error.

---
 tools/libxl/libxl_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_pci.c +1 -1
index 1ebdce7..19c597e 100644
@@ -123,7 +123,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d
     flexarray_t *back;
     char *num_devs, *be_path;
     int num = 0;
-    xs_transaction_t t;
+    xs_transaction_t t = XBT_NULL;
     libxl__device *device;
     int rc;
     libxl_domain_config d_config;
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw

On Wed, 2015-09-16 at 14:16 +0800, Chunyan Liu wrote:

For the subject I prefer to avoid "fix <vague>" style messages. In this case something like "libxl: ensure xs transaction is initialised in libxl__device_pci_add_xenstore" would be better.

Quoted 6 lines

Run "xl pci-attach <pci_device>", the 2nd time fails:
xl: libxl_xshelp.c:209: libxl__xs_transaction_start: Assertion `!*t' failed. Aborted

To fix that, initialize xs_transaction to avoid
libxl__xs_transaction_start assertation error.

"assertion".

Quoted 1 line

With an updated commit message (which I can do as I commit):

Wei, I think we want this for 4.6.

Ian, tools/libxl/libxl_internal.h says to initialised the transaction to 0 rather than XBT_NULL explicitly -- I don't think there is a specific reason for that though?

Quoted 18 lines
---
 tools/libxl/libxl_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_pci.c +1 -1
index 1ebdce7..19c597e 100644
@@ -123,7 +123,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc
 *gc, uint32_t domid, libxl_d
     flexarray_t *back;
     char *num_devs, *be_path;
     int num = 0;
-    xs_transaction_t t;
+    xs_transaction_t t = XBT_NULL;
     libxl__device *device;
     int rc;
     libxl_domain_config d_config;
#2 lore raw

Ian Campbell writes ("Re: [PATCH] pci-attach: fix assertation"):

Quoted 3 lines

Ian, tools/libxl/libxl_internal.h says to initialised the transaction to 0 rather than XBT_NULL explicitly -- I don't think there is a specific reason for that though?

It says:

/* Transaction functions, best used together.
* The caller should initialise *t to 0 (XBT_NULL) before calling start.

I think that amounts to a promise that XBT_NULL == 0. Therefore the caller may (from a correctness pov) use either.

It is important that initialisation with 0 is supported because then FILLZERO is known to DTRT. (Note that, analogously, we are already assuming that FILLZERO generates null pointers.)

I know that some people have strong views that writing NULL for null pointers, rather than 0, is better. I think it is needless verbiage. A similar argument applies to XBT_NULL. I think this is a bikeshed and am happy to let it be whatever colour it comes from the factory :-).

Ian.

#3 lore raw
Quoted 7 lines · Ian Jackson

Ian Campbell writes ("Re: [PATCH] pci-attach: fix assertation"):

Quoted 5 lines

Ian, tools/libxl/libxl_internal.h says to initialised the transaction to 0
rather than XBT_NULL explicitly -- I don't think there is a specific reason
for that though?

Quoted 7 lines

It says:

/* Transaction functions, best used together.
* The caller should initialise *t to 0 (XBT_NULL) before calling start.

I think that amounts to a promise that XBT_NULL == 0. Therefore the caller may (from a correctness pov) use either.

Agreed, I just wanted to be sure there wasn't some magic reason to avoid XBT_NULL (other than, as you say, needless verbiage).

Quoted 3 lines

It is important that initialisation with 0 is supported because then FILLZERO is known to DTRT. (Note that, analogously, we are already assuming that FILLZERO generates null pointers.)

Right.

Quoted 5 lines

I know that some people have strong views that writing NULL for null pointers, rather than 0, is better. I think it is needless verbiage. A similar argument applies to XBT_NULL. I think this is a bikeshed and am happy to let it be whatever colour it comes from the factory :-).

Ack.

#4 lore raw
In reply to Ian Campbell
Quoted 13 lines · Ian Campbell

On Wed, 2015-09-16 at 14:16 +0800, Chunyan Liu wrote:

For the subject I prefer to avoid "fix <vague>" style messages. In this case something like "libxl: ensure xs transaction is initialised in libxl__device_pci_add_xenstore" would be better.

Quoted 6 lines

Run "xl pci-attach <pci_device>", the 2nd time fails:
xl: libxl_xshelp.c:209: libxl__xs_transaction_start: Assertion `!*t' failed. Aborted

To fix that, initialize xs_transaction to avoid
libxl__xs_transaction_start assertation error.

Quoted 9 lines

"assertion".

Quoted 1 line

With an updated commit message (which I can do as I commit):

Wei, I think we want this for 4.6.

Applied
#5 lore raw
Quoted 19 lines · Wei Liu
Quoted 18 lines · Ian Campbell

On Wed, 2015-09-16 at 14:16 +0800, Chunyan Liu wrote:

For the subject I prefer to avoid "fix <vague>" style messages. In this case something like "libxl: ensure xs transaction is initialised in libxl__device_pci_add_xenstore" would be better.

Quoted 7 lines

Run "xl pci-attach <pci_device>", the 2nd time fails:
xl: libxl_xshelp.c:209: libxl__xs_transaction_start: Assertion `!*t' failed.
Aborted

To fix that, initialize xs_transaction to avoid
libxl__xs_transaction_start assertation error.

"assertion".

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

With an updated commit message (which I can do as I commit):

Wei, I think we want this for 4.6.

Applied to staging and staging-4.6.