Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[guest-efi] Add varstored-watch #69

Merged
merged 1 commit into from
Oct 28, 2021
Merged

Conversation

tsirakisn
Copy link
Contributor

varstored-watch is a helper binary that starts and
monitors an instance of varstored.

OXT-1826

Signed-off-by: Nicholas Tsirakis [email protected]

Comment on lines 10 to 15
varstored-watch: varstored-watch.o
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@

%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete all this and let the implicit rules do the work for you.

Comment on lines 1 to 2
INCDIR ?= /usr/include
LIBDIR ?= /usr/lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

INCDIR ?= /usr/include
LIBDIR ?= /usr/lib

LIBFLAGS = -lxenctrl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to
LDLIBS = -lxenctrl

LIBDIR ?= /usr/lib

LIBFLAGS = -lxenctrl
CFLAGS = -I${INCDIR} -g -Wall -Werror
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CFLAGS += -g -Wall -Werror

rm -f varstored-watch *.o

install:
install -m 0755 varstored-watch /usr/sbin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could take a D/DESTDIR prefix and then you could do make install for the OE recipe.

goto err;
}
if (dominfo.shutdown == true) {
syslog(LOG_ERR, "Domid %u is shutting down.\n", domid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nicer to avoid having to open xc_interface to avoid the need for privcmd permissions. Would checking /local/domain/$domid be sufficient as an existence check? libxl will kill this process, so it doesn't need to exit itself on domain shutdown.

Copy link
Contributor

@jandryuk jandryuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

@@ -0,0 +1,15 @@
CFLAGS += -g -Wall -Werror
LDLIBS = -lxenctrl -lxenstore
LDFLAGS = -L${LIBDIR} ${LDLIBS}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIBDIR is no longer defined. You can drop more like so:

diff --git a/varstored-watch/Makefile b/varstored-watch/Makefile
index 76574d5..4498895 100644
--- a/varstored-watch/Makefile
+++ b/varstored-watch/Makefile
@@ -1,12 +1,8 @@
 CFLAGS  += -g -Wall -Werror
 LDLIBS   = -lxenctrl -lxenstore
-LDFLAGS  = -L${LIBDIR} ${LDLIBS}
 
 all: varstored-watch
 
-varstored-watch: varstored-watch.o
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
-
 clean:
        rm -f varstored-watch *.o
 

} else if (WIFSIGNALED(rc)) {
syslog(LOG_ERR, "Varstored killed by signal %d, restarting.\n", WTERMSIG(rc));
varstored_pid = start_varstored(xsh, domid_str, uuid);
} else if (WIFSTOPPED(rc)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    WIFSTOPPED(wstatus)
              returns true if the child process was stopped by delivery  of  a
              signal;  this  is  possible only if the call was done using WUN‐
              TRACED or when the child is being traced (see ptrace(2)).

The process hasn't died - it has just been stopped. SIGCONT would resume it, I think? Therefore starting a new varstored doesn't seem right. WUNTRACED is not set in waitpid options through, so it would only happen under ptrace. In case someone does ptrace varstored, I'd just remove the WIFSTOPPED case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point. Didn't catch the nuance there, removing.

ret = -1;
done:
if (xsh)
xs_close(xsh);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xsh is open for the lifetime of the program, but it's only used in xs_write_pid. The handle's fd probably leaks into the child varstored? Why don't you move xs_open/xs_close into xs_write_pid to keep it all together and avoid that.

varstored-watch is a helper binary that starts and
monitors an instance of varstored.

OXT-1826

Signed-off-by: Nicholas Tsirakis <[email protected]>
Copy link
Contributor

@jandryuk jandryuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes.

Copy link
Contributor

@crogers1 crogers1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging with OpenXT/xenclient-oe#1434

@jandryuk jandryuk merged commit 6decdfb into OpenXT:master Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants