]> xenbits.xensource.com Git - people/larsk/xen.git/commit
libxl: synchronise configuration when we hotplug a device
authorWei Liu <wei.liu2@citrix.com>
Tue, 16 Sep 2014 10:01:12 +0000 (11:01 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 17 Sep 2014 18:59:10 +0000 (19:59 +0100)
commit4197d3abbb3055d3798254eb7ba239bfb5824360
treea02f2e7ba44d14d9f9bb6f63f2ec690600fe7e32
parenta788fe0cd8bcb51ef167fc451f837066362d8c82
libxl: synchronise configuration when we hotplug a device

We update JSON version first, then write to xenstore, so that we
maintain the following invariant: any device which is present in
xenstore has a corresponding entry in JSON.

The workflow is as followed:
   lock json config
       read json config
       update in-memory json config with new entry, replacing
         any stale entry
       for loop
           open xs transaction
           check device existence, abort if it exists
           write in-memory json config to disk
           commit xs transaction
       end for loop
   unlock json config

Please see comment in libxl_internal.h for correctness proof.

As those routines are called both during domain creation and device
hotplug, we add a flag to indicate whether we need to update JSON
config. This flag is only set to true when we hotplug a device. We
cannot update JSON config during domain creation as JSON config is
committed to disk only when domain creation finishes.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_pci.c