tools/xenstored: fix live update
PATCH 1/1 tools/xenstored: fix live update
Commit e5b0a940557 ("tools/xenstored: Auto-introduce domains") broke xenstored live update, as init_domains() will be skipped when live update is detected to have happened. This will leave priv_domid and store_domid set as invalid.
Fix that by calling init_domains() in live update case, too. In case of live update skip introducing any found domains, as this will be done when reading the live update state.
--- tools/xenstored/core.c | 3 ++- tools/xenstored/domain.c | 20 +++++++++++++------- tools/xenstored/domain.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-)
tools/xenstored/core.c +2 -1
@@ -2763,7 +2763,7 @@ int main(int argc, char *argv[])/* Listen to hypervisor. */ if (!live_update) {domain_init (-1 ); -init_domains (); +init_domains (false); }/* redirect to /dev/null now we're ready to accept connections */
@@ -3109,6 +3109,7 @@ void read_state_global(const void *ctx, const void *state)set_socket_fd (glb->socket_fd);domain_init (glb->evtchn_fd); +init_domains (true); } static void add_buffered_data(struct buffered_data *bdata,
tools/xenstored/domain.c +13 -7
@@ -1344,7 +1344,7 @@ static bool init_domain(unsigned int domid)return true; } -void init_domains (void ) +void init_domains (bool live_update) {unsigned int *domids =NULL ;unsigned int nr_domids =0 ;
@@ -1356,12 +1356,15 @@ void init_domains(void)while (!xenmanage_poll_changed_domain (xm_handle, &domid, &state, &caps, &unique_id)) { - nr_domids++; - domids = talloc_realloc(NULL, domids, unsigned int, nr_domids); -if (!domids) -barf_perror ("Failed to reallocate domids" ); - - domids[nr_domids -1 ] = domid; +if (!live_update) { + nr_domids++; + domids =talloc_realloc (NULL , domids, + unsigned int, nr_domids); +if (!domids) +barf_perror ("Failed to reallocate domids" ); + + domids[nr_domids -1 ] = domid; + }if (caps &XENMANAGE_GETDOMSTATE_CAP_CONTROL ) {/*
@@ -1397,6 +1400,9 @@ void init_domains(void)snprintf (store_domain_path,sizeof (store_domain_path),"/local/domain/%u" , store_domid); +if (live_update) +return ; +/* * Privileged domid must be first to setup structures for firing the * special watches.
tools/xenstored/domain.h +1 -1
@@ -92,7 +92,7 @@ int do_set_feature(const void *ctx, struct connection *conn,void domain_early_init (void );void domain_init (int evtfd); -void init_domains (void ); +void init_domains (bool live_update);void stubdom_init (bool live_update);void domain_deinit (void );void ignore_connection (struct connection *conn,unsigned int err);
Signature · 1 line
2.53.0
Quoted 11 lines · Juergen Gross
Commit
e5b0a940557("tools/xenstored: Auto-introduce domains") broke xenstored live update, asinit_domains()will be skipped when live update is detected to have happened. This will leavepriv_domidandstore_domidset as invalid.Fix that by calling
init_domains()in live update case, too. In case of live update skip introducing any found domains, as this will be done when reading the live update state.Fixes e5b0a940557 ("tools/xenstored: Auto-introduce domains")Signed-off-by Juergen Gross <[email protected]>