Skip to contentSkip to conversation

NetBSD: minor fixes and hotplug execution

PATCH Superseded Roger Pau Monne 4 participants 48 messages Jul 11, 2012 – Jul 25, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover NetBSD: minor fixes and hotplug execution

This series contains minor fixes to build xen on NetBSD and adds hotplug support to NetBSD. After this, xen-unstable should build and work out-of-the-box on NetBSD.

This fixes are not related, and as far as I know, can be applied sepparetedly:

[PATCH 1/9] xenstore: don't print an error when gntdev cannot be [PATCH 2/9] tools/build: fix pygrub linking
[PATCH 3/9] pygrub: don't leave fds open
[PATCH 4/9] build: include Tools.mk first in tools/Rules.mk [PATCH 5/9] libxl: react correctly to POLLHUP
[PATCH 6/9] libxl: check backend state before setting it to [PATCH 7/9] hotplug/NetBSD: check type of file to attach from params

This two should be applied together:

[PATCH 8/9] libxl: call hotplug scripts from xl for NetBSD [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Thanks, Roger.

#1 lore raw

PATCH 1/9 xenstore: don't print an error when gntdev cannot be opened

NetBSD doesn't have a gntdev, but we should not print an error when falling back to the previous implementation.

---
 tools/libxc/xc_private.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxc/xc_private.c +1 -1
index 3ceed3e..3e03a91 100644
@@ -174,7 +174,7 @@ static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *log
         xch->ops = xch->osdep.init(xch, type);
         if ( xch->ops == NULL )
         {
-            ERROR("OSDEP: interface %d (%s) not supported on this platform",
+            DPRINTF("OSDEP: interface %d (%s) not supported on this platform",
                   type, xc_osdep_type_name(type));
             goto err_put_iface;
         }
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] xenstore: don't print an error when gntdev cannot be opened

Quoted 4 lines · Roger Pau Monne

NetBSD doesn't have a gntdev, but we should not print an error when falling back to the previous implementation.

Seems reasonable.

Quoted 17 lines
---
 tools/libxc/xc_private.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxc/xc_private.c +1 -1
index 3ceed3e..3e03a91 100644
@@ -174,7 +174,7 @@ static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *log
         xch->ops = xch->osdep.init(xch, type);
         if ( xch->ops == NULL )
         {
-            ERROR("OSDEP: interface %d (%s) not supported on this platform",
+            DPRINTF("OSDEP: interface %d (%s) not supported on this platform",
                   type, xc_osdep_type_name(type));
             goto err_put_iface;
         }
#3 lore raw

PATCH 2/9 tools/build: fix pygrub linking

In reply to Roger Pau Monne

Prevent creating a symlink to $(DESTDIR)/$(BINDIR) if it is the same as $(PRIVATE_BINDIR)

This fixes NetBSD install, where $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR).

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
---
 tools/pygrub/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/pygrub/Makefile +2 -0
index bd22dd4..835fd43 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+#ifneq ($(readlink -f $(PRIVATE_BINDIR)), $(readlink -f $(DESTDIR)/$(BINDIR)))
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+#endif
 
 .PHONY: clean
 clean:
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 9 lines · Roger Pau Monne

Prevent creating a symlink to $(DESTDIR)/$(BINDIR) if it is the same as $(PRIVATE_BINDIR)

This fixes NetBSD install, where $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR).

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
Quoted 18 lines
---
 tools/pygrub/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/pygrub/Makefile +2 -0
index bd22dd4..835fd43 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+#ifneq ($(readlink -f $(PRIVATE_BINDIR)), $(readlink -f $(DESTDIR)/$(BINDIR)))
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+#endif
 
 .PHONY: clean
 clean:
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#5 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 19 lines · Christoph Egger
Quoted 9 lines · Roger Pau Monne

Prevent creating a symlink to $(DESTDIR)/$(BINDIR) if it is the same as $(PRIVATE_BINDIR)

This fixes NetBSD install, where $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR).

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
Quoted 4 lines
---
 tools/pygrub/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 11 lines

tools/pygrub/Makefile install: all · line 19

Quoted 11 lines
tools/pygrub/Makefile +2 -0
index bd22dd4..835fd43 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+#ifneq ($(readlink -f $(PRIVATE_BINDIR)), $(readlink -f $(DESTDIR)/$(BINDIR)))
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+#endif

I'm afraid I've not removed the "#" here (don't know why I've put them on the first place), and also $(shell ...) should be used to get the output. This is the correct path:

8<---------------------------------------------------------------------

Subject: [PATCH] tools/build: fix pygrub linking

Prevent creating a symlink to $(DESTDIR)/$(BINDIR) if it is the same as $(PRIVATE_BINDIR)

This fixes NetBSD install, where $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR).

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
---
 tools/pygrub/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/pygrub/Makefile +1 -0
index bd22dd4..182afdd 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+ifneq ($(shell readlink -f $(DESTDIR)/$(BINDIR)), $(shell readlink -f

$(PRIVATE_BINDIR)))
ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+endif

.PHONY: clean
clean:

Signature · 1 line
1.7.7.5 (Apple Git-26)
#6 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

tools/pygrub/Makefile install: all · line 20

Quoted 12 lines
tools/pygrub/Makefile +2 -0
index bd22dd4..182afdd 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+ifneq ($(shell readlink -f $(DESTDIR)/$(BINDIR)), $(shell readlink -f
 $(PRIVATE_BINDIR)))
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+endif

Why are we doing all this work in make with $(shell...) rather than simply in the command stanza ?

Also I'm a bit confused. This problem occurs only when DESTDIR="" ? In which case perhaps the right answer is something like

        set -e; if ! test -e $(DESTDIR)/$(BINDIR)/pygrub; then \
            ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR); \
        fi

Ian.

#7 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 17 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

tools/pygrub/Makefile install: all · line 20

Quoted 12 lines
tools/pygrub/Makefile +2 -0
index bd22dd4..182afdd 100644
@@ -14,7 +14,9 @@ install: all
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
 		--install-scripts=$(PRIVATE_BINDIR) --force
 	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
+ifneq ($(shell readlink -f $(DESTDIR)/$(BINDIR)), $(shell readlink -f
 $(PRIVATE_BINDIR)))
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+endif

Why are we doing all this work in make with $(shell...) rather than simply in the command stanza ?

Quoted 1 line

Also I'm a bit confused. This problem occurs only when DESTDIR="" ?

No, this occurs when $(BINDIR) == $(PRIVATE_BINDIR), but we cannot use the "test -e", because we might have previous versions of pygrub installed which should also be overwritten by the link, or the user will keep using the old version.

Quoted 6 lines

In which case perhaps the right answer is something like

        set -e; if ! test -e $(DESTDIR)/$(BINDIR)/pygrub; then \
            ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR); \
        fi

Ian.

#8 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 10 lines
Quoted 9 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Review

Quoted 4 lines

+ifneq ($(shell readlink -f $(DESTDIR)/$(BINDIR)), $(shell readlink -f $(PRIVATE_BINDIR)))

(quoted diff) +1 -0
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+endif

Why are we doing all this work in make with $(shell...) rather than simply in the command stanza ?

Quoted 6 lines
Quoted 1 line

Also I'm a bit confused. This problem occurs only when DESTDIR="" ?

No, this occurs when $(BINDIR) == $(PRIVATE_BINDIR), but we cannot use the "test -e", because we might have previous versions of pygrub installed which should also be overwritten by the link, or the user will keep using the old version.

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ian.

#9 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 10 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 9 lines
Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Review

Quoted 4 lines

+ifneq ($(shell readlink -f $(DESTDIR)/$(BINDIR)), $(shell readlink -f $(PRIVATE_BINDIR)))

(quoted diff) +1 -0
 	ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)
+endif

Why are we doing all this work in make with $(shell...) rather than simply in the command stanza ?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Also I'm a bit confused. This problem occurs only when DESTDIR="" ?

No, this occurs when $(BINDIR) == $(PRIVATE_BINDIR), but we cannot use the "test -e", because we might have previous versions of pygrub installed which should also be overwritten by the link, or the user will keep using the old version.

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ok, both conditions have to be meet, that DESTDIR == "" and PRIVATE_BINDIR == BINDIR (so $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR)).

#10 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 6 lines
Quoted 2 lines · Ian Jackson

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ok, both conditions have to be meet, that DESTDIR == "" and PRIVATE_BINDIR == BINDIR (so $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR)).

Right. OK. I see now why my test -e is wrong.

But I still think this should be done with an if in the rule's command, rather than a makefile conditional.

Ian.

#11 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 11 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 5 lines
Quoted 2 lines · Ian Jackson

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ok, both conditions have to be meet, that DESTDIR == "" and PRIVATE_BINDIR == BINDIR (so $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR)).

Right. OK. I see now why my test -e is wrong.

But I still think this should be done with an if in the rule's command, rather than a makefile conditional.

What do you think about:

set -e; if [ `readlink -f $(DESTDIR)/$(BINDIR)` != \
             `readlink -f $(PRIVATE_BINDIR)` ]; then \
                ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR); \

fi

#12 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 13 lines
Quoted 11 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 5 lines
Quoted 2 lines · Ian Jackson

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ok, both conditions have to be meet, that DESTDIR == "" and PRIVATE_BINDIR == BINDIR (so $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR)).

Right. OK. I see now why my test -e is wrong.

But I still think this should be done with an if in the rule's command, rather than a makefile conditional.

Quoted 6 lines

What do you think about:

set -e; if [ `readlink -f $(DESTDIR)/$(BINDIR)` != \
             `readlink -f $(PRIVATE_BINDIR)` ]; then \
                ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR); \

fi

That looks plausible.

Can we assume that we are using bash as our shell for these commands ? If so we can use `test A -ef B'.

Ian.

#13 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Quoted 19 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 9 lines
Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 5 lines
Quoted 2 lines · Ian Jackson

If DESTDIR is not "" then $(PRIVATE_BINDIR)/pygrub is not the same directory as $(DESTDIR)/$(BINDIR).

Ok, both conditions have to be meet, that DESTDIR == "" and PRIVATE_BINDIR == BINDIR (so $(DESTDIR)/$(BINDIR) == $(PRIVATE_BINDIR)).

Right. OK. I see now why my test -e is wrong.

Quoted 8 lines
Quoted 2 lines

But I still think this should be done with an if in the rule's command, rather than a makefile conditional.

What do you think about:

set -e; if [ `readlink -f $(DESTDIR)/$(BINDIR)` != \
             `readlink -f $(PRIVATE_BINDIR)` ]; then \
                ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR); \

fi

Quoted 4 lines

That looks plausible.

Can we assume that we are using bash as our shell for these commands ? If so we can use `test A -ef B'.

I wouldn't make such an assumption, I've build Xen on systems without bash (Alpine Linux and NetBSD).

#14 lore raw

Re: [PATCH 2/9] tools/build: fix pygrub linking

Roger Pau Monne writes ("Re: [PATCH 2/9] tools/build: fix pygrub linking"):

Quoted 6 lines
Quoted 2 lines · Ian Jackson

Can we assume that we are using bash as our shell for these commands ? If so we can use `test A -ef B'.

I wouldn't make such an assumption, I've build Xen on systems without bash (Alpine Linux and NetBSD).

OK then, the rune you posted looks reasonable to me assuming someone has tested it :-). I'll ack the full patch when I see it.

Ian.

#15 lore raw

PATCH 3/9 pygrub: don't leave fds open

In reply to Roger Pau Monne

On NetBSD a block device can only be opened once, so make sure pygrub closes it every time, if this is not done libfsimage is not able to open the disk later.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
---
 tools/pygrub/src/pygrub |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
tools/pygrub/src/pygrub +3 -0
index 6dd44ac..ad78c22 100644
@@ -67,6 +67,7 @@ def get_solaris_slice(file, offset):
     fd = os.open(file, os.O_RDONLY)
     os.lseek(fd, offset + (DK_LABEL_LOC * SECTOR_SIZE), 0)
     buf = os.read(fd, 512)
+    os.close(fd)
     if struct.unpack("<H", buf[508:510])[0] != DKL_MAGIC:
         raise RuntimeError, "Invalid disklabel magic"
 
@@ -93,6 +94,7 @@ def get_fs_offset_gpt(file):
         buf = os.read(fd, partsize)
         offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE)
         i -= 1
+    os.close(fd)
     return offsets
 
 FDISK_PART_SOLARIS=0xbf
@@ -116,6 +118,7 @@ def get_partition_offsets(file):
 
     fd = os.open(file, os.O_RDONLY)
     buf = os.read(fd, 512)
+    os.close(fd)
     for poff in (446, 462, 478, 494): # partition offsets
 
         # MBR contains a 16 byte descriptor per partition
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 3/9
#16 lore raw

Re: [PATCH 3/9] pygrub: don't leave fds open

Quoted 7 lines · Roger Pau Monne

On NetBSD a block device can only be opened once, so make sure pygrub closes it every time, if this is not done libfsimage is not able to open the disk later.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
Quoted 32 lines
---
 tools/pygrub/src/pygrub |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
tools/pygrub/src/pygrub +3 -0
index 6dd44ac..ad78c22 100644
@@ -67,6 +67,7 @@ def get_solaris_slice(file, offset):
     fd = os.open(file, os.O_RDONLY)
     os.lseek(fd, offset + (DK_LABEL_LOC * SECTOR_SIZE), 0)
     buf = os.read(fd, 512)
+    os.close(fd)
     if struct.unpack("<H", buf[508:510])[0] != DKL_MAGIC:
         raise RuntimeError, "Invalid disklabel magic"
 
@@ -93,6 +94,7 @@ def get_fs_offset_gpt(file):
         buf = os.read(fd, partsize)
         offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE)
         i -= 1
+    os.close(fd)
     return offsets
 
 FDISK_PART_SOLARIS=0xbf
@@ -116,6 +118,7 @@ def get_partition_offsets(file):
 
     fd = os.open(file, os.O_RDONLY)
     buf = os.read(fd, 512)
+    os.close(fd)
     for poff in (446, 462, 478, 494): # partition offsets
 
         # MBR contains a 16 byte descriptor per partition
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
Acked-by on v1 3/9
#17 lore raw

Re: [PATCH 3/9] pygrub: don't leave fds open

In reply to Roger Pau Monne

Roger Pau Monne writes ("[PATCH 3/9] pygrub: don't leave fds open"):

Quoted 7 lines

On NetBSD a block device can only be opened once, so make sure pygrub closes it every time, if this is not done libfsimage is not able to open the disk later.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>

Looks plausible to me.

Although:

Quoted 4 lines

fd = os.open(file, os.O_RDONLY)
os.lseek(fd, offset + (DK_LABEL_LOC * SECTOR_SIZE), 0) buf = os.read(fd, 512)
+ os.close(fd)

...

Quoted 3 lines

fd = os.open(file, os.O_RDONLY)
buf = os.read(fd, 512)
+ os.close(fd)

These are two remarkably similar bits of code which might deserve a function.

Ian.

#18 lore raw

PATCH 4/9 build: include Tools.mk first in tools/Rules.mk

In reply to Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 4/9
#19 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

Quoted 4 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Quoted 18 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#20 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

In reply to Roger Pau Monne
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

Quoted 20 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
#21 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

Quoted 8 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

When you specify --prefix to configure then this has no effect w/o this patch.

Christoph

Quoted 28 lines
Quoted 11 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +0 -0
index 1e928b7..2dd8ed3 100644

tools/Rules.mk line 10

Quoted 9 lines
tools/Rules.mk +1 -1
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#22 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

In reply to Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

$(XEN_ROOT)/Config.mk includes config/{Linux.mk/NetBSD.mk} and config/StdGNU.mk, which contain a bunch of paths, specially config/StdGNU.mk. If the tools config file is not loaded before, all this paths get set to the default value (which is probably fine in Linux), but not desirable in NetBSD if the user has specified a custom prefix.

So the main problem is that the tools Makefile should include config/Tools.mk before config/StdGNU.mk, but since config/StdGNU.mk is included in $(XEN_ROOT)/Config.mk we have to either include Tools.mk before $(XEN_ROOT)/Config.mk or modify $(XEN_ROOT)/Config.mk to include Tools.mk (which is not desirable at all). I don't care that $(XEN_ROOT)/Config.mk uses the default paths when building the xen kernel, but we should honour the user set paths when installing the tools.

One effect of this patch is that etc and var is installed inside of $(PREFIX)/etc, which is normal in BSD systems, but I'm quite sure it is not correct on Linux, so I should add the following chunk:

config/Linux.mk +5 -0
@@ -6,3 +6,8 @@ KERNELS ?=
 XKERNELS := $(foreach kernel, $(KERNELS), \
               $(patsubst buildconfigs/mk.%,%, \
                 $(wildcard buildconfigs/mk.$(kernel))) )
+
+CONFIG_DIR = /etc
+XEN_LOCK_DIR = /var/lock
+XEN_RUN_DIR = /var/run/xen
+XEN_PAGING_DIR = /var/lib/xen/xenpaging
Quoted 21 lines
Quoted 19 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
#23 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

Quoted 17 lines · Roger Pau Monne
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

$(XEN_ROOT)/Config.mk includes config/{Linux.mk/NetBSD.mk} and config/StdGNU.mk, which contain a bunch of paths, specially config/StdGNU.mk. If the tools config file is not loaded before, all this paths get set to the default value (which is probably fine in Linux), but not desirable in NetBSD if the user has specified a custom prefix.

Quoted 7 lines

So the main problem is that the tools Makefile should include config/Tools.mk before config/StdGNU.mk, but since config/StdGNU.mk is included in $(XEN_ROOT)/Config.mk we have to either include Tools.mk before $(XEN_ROOT)/Config.mk or modify $(XEN_ROOT)/Config.mk to include Tools.mk (which is not desirable at all). I don't care that $(XEN_ROOT)/Config.mk uses the default paths when building the xen kernel, but we should honour the user set paths when installing the tools.

My point was that really all of these paths should move to autoconf and Tools.mk.in. But for 4.2 I guess your proposed change is more appropriate.

Quoted 3 lines

One effect of this patch is that etc and var is installed inside of $(PREFIX)/etc, which is normal in BSD systems, but I'm quite sure it is not correct on Linux, so I should add the following chunk:

StdGNU explicitly has:

        ifeq ($(PREFIX),/usr)
        CONFIG_DIR = /etc
        XEN_LOCK_DIR = /var/lock
        XEN_RUN_DIR = /var/run/xen
        XEN_PAGING_DIR = /var/lib/xen/xenpaging
        else
        CONFIG_DIR = $(PREFIX)/etc
        XEN_LOCK_DIR = $(PREFIX)/var/lock
        XEN_RUN_DIR = $(PREFIX)/var/run/xen
        XEN_PAGING_DIR = $(PREFIX)/var/lib/xen/xenpaging
        endif

so it looks like this was at least deliberate.

Quoted 35 lines
config/Linux.mk +5 -0
@@ -6,3 +6,8 @@ KERNELS ?=
 XKERNELS := $(foreach kernel, $(KERNELS), \
               $(patsubst buildconfigs/mk.%,%, \
                 $(wildcard buildconfigs/mk.$(kernel))) )
+
+CONFIG_DIR = /etc
+XEN_LOCK_DIR = /var/lock
+XEN_RUN_DIR = /var/run/xen
+XEN_PAGING_DIR = /var/lib/xen/xenpaging
Quoted 22 lines
Quoted 20 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
#24 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

Quoted 24 lines · Ian Campbell
Quoted 15 lines · Roger Pau Monne
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

$(XEN_ROOT)/Config.mk includes config/{Linux.mk/NetBSD.mk} and config/StdGNU.mk, which contain a bunch of paths, specially config/StdGNU.mk. If the tools config file is not loaded before, all this paths get set to the default value (which is probably fine in Linux), but not desirable in NetBSD if the user has specified a custom prefix.

Quoted 7 lines

So the main problem is that the tools Makefile should include config/Tools.mk before config/StdGNU.mk, but since config/StdGNU.mk is included in $(XEN_ROOT)/Config.mk we have to either include Tools.mk before $(XEN_ROOT)/Config.mk or modify $(XEN_ROOT)/Config.mk to include Tools.mk (which is not desirable at all). I don't care that $(XEN_ROOT)/Config.mk uses the default paths when building the xen kernel, but we should honour the user set paths when installing the tools.

Quoted 3 lines

My point was that really all of these paths should move to autoconf and Tools.mk.in. But for 4.2 I guess your proposed change is more appropriate.

Yes, this is just a bandaid to hide a much bigger problem we have with paths & makefiles in general.

Quoted 16 lines
Quoted 3 lines

One effect of this patch is that etc and var is installed inside of $(PREFIX)/etc, which is normal in BSD systems, but I'm quite sure it is not correct on Linux, so I should add the following chunk:

StdGNU explicitly has:

        ifeq ($(PREFIX),/usr)
        CONFIG_DIR = /etc
        XEN_LOCK_DIR = /var/lock
        XEN_RUN_DIR = /var/run/xen
        XEN_PAGING_DIR = /var/lib/xen/xenpaging
        else
        CONFIG_DIR = $(PREFIX)/etc
        XEN_LOCK_DIR = $(PREFIX)/var/lock
        XEN_RUN_DIR = $(PREFIX)/var/run/xen
        XEN_PAGING_DIR = $(PREFIX)/var/lib/xen/xenpaging
        endif
Quoted 1 line

so it looks like this was at least deliberate.

Yes, this was the behaviour we had before the autoconf patch, when PREFIX was specified in .config (which I find strange in a Linux system). So I'm not going to add this chunk and leave the patch as-is.

Thanks.

Quoted 35 lines
Quoted 33 lines
config/Linux.mk +5 -0
@@ -6,3 +6,8 @@ KERNELS ?=
 XKERNELS := $(foreach kernel, $(KERNELS), \
               $(patsubst buildconfigs/mk.%,%, \
                 $(wildcard buildconfigs/mk.$(kernel))) )
+
+CONFIG_DIR = /etc
+XEN_LOCK_DIR = /var/lock
+XEN_RUN_DIR = /var/run/xen
+XEN_PAGING_DIR = /var/lib/xen/xenpaging
Quoted 21 lines
Quoted 20 lines
---
 tools/Rules.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/Rules.mk +1 -1
index 1e928b7..2dd8ed3 100644
@@ -3,8 +3,8 @@
 # `all' is the default target
 all:
 
-include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Tools.mk
+include $(XEN_ROOT)/Config.mk
 
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
Acked-by
#25 lore raw

Re: [PATCH 4/9] build: include Tools.mk first in tools/Rules.mk

Quoted 25 lines · Roger Pau Monne
Quoted 24 lines · Ian Campbell
Quoted 22 lines · Roger Pau Monne
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Roger Pau Monne

Tools.mk should be included first, or PREFIX is not honoured in the other conf/ files that define the paths of several tools.

Isn't it a bug for anything which is included/defined via $(XEN_ROOT)/Config.mk to depend on the contents of $(XEN_ROOT)/config/Tools.mk since for anything non-tools Tools.mk would never be included at all?

$(XEN_ROOT)/Config.mk includes config/{Linux.mk/NetBSD.mk} and config/StdGNU.mk, which contain a bunch of paths, specially config/StdGNU.mk. If the tools config file is not loaded before, all this paths get set to the default value (which is probably fine in Linux), but not desirable in NetBSD if the user has specified a custom prefix.

So the main problem is that the tools Makefile should include config/Tools.mk before config/StdGNU.mk, but since config/StdGNU.mk is included in $(XEN_ROOT)/Config.mk we have to either include Tools.mk before $(XEN_ROOT)/Config.mk or modify $(XEN_ROOT)/Config.mk to include Tools.mk (which is not desirable at all). I don't care that $(XEN_ROOT)/Config.mk uses the default paths when building the xen kernel, but we should honour the user set paths when installing the tools.

Quoted 6 lines
Quoted 3 lines

My point was that really all of these paths should move to autoconf and Tools.mk.in. But for 4.2 I guess your proposed change is more appropriate.

Yes, this is just a bandaid to hide a much bigger problem we have with paths & makefiles in general.

OK then.

and applied, thanks.

#26 lore raw

PATCH 5/9 libxl: react correctly to POLLHUP

In reply to Roger Pau Monne

On datacopier_readable ignore PULLHUP, since we will shortly process the death of the underlying process.

---
 tools/libxl/libxl_aoutils.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
tools/libxl/libxl_aoutils.c +8 -0
index 99972a2..fa07154 100644
@@ -102,6 +102,14 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev,
     libxl__datacopier_state *dc = CONTAINER_OF(ev, *dc, toread);
     STATE_AO_GC(dc->ao);
 
+    if (revents & POLLHUP) {
+        LOG(DEBUG, "received POLLHUP on %s during copy of %s, "
+                   "waiting for process to die",
+                   dc->readwhat, dc->copywhat);
+        libxl__ev_fd_deregister(gc, &dc->toread);
+        return;
+    }
+
     if (revents & ~POLLIN) {
         LOG(ERROR, "unexpected poll event 0x%x (should be POLLIN)"
             " on %s during copy of %s", revents, dc->readwhat, dc->copywhat);
Signature · 1 line
1.7.7.5 (Apple Git-26)
Nacked-by on v1 5/9 NAK
#27 lore raw

Re: [PATCH 5/9] libxl: react correctly to POLLHUP

Roger Pau Monne writes ("[PATCH 5/9] libxl: react correctly to POLLHUP"):

Quoted 2 lines

On datacopier_readable ignore PULLHUP, since we will shortly process the death of the underlying process.

As discussed,

Ian.

#28 lore raw

PATCH 6/9 libxl: check backend state before setting it to "closing"

In reply to Roger Pau Monne

Check backend state before unconditionally setting it to "closing" (5), since it might already be in "closed" (6).

---
 tools/libxl/libxl_device.c |   53 +++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 15 deletions(-)
tools/libxl/libxl_device.c +38 -15
index 8ae2bb5..18002a0 100644
@@ -681,10 +681,11 @@ void libxl__initiate_device_remove(libxl__egc *egc,
                                    libxl__ao_device *aodev)
 {
     STATE_AO_GC(aodev->ao);
-    libxl_ctx *ctx = libxl__gc_owner(gc);
     xs_transaction_t t = 0;
     char *be_path = libxl__device_backend_path(gc, aodev->dev);
     char *state_path = libxl__sprintf(gc, "%s/state", be_path);
+    char *online_path = GCSPRINTF("%s/online", be_path);
+    const char *state;
     int rc = 0;
 
     /* We init this here because we might call device_hotplug_done
@@ -701,23 +702,44 @@ void libxl__initiate_device_remove(libxl__egc *egc,
         goto out;
     }
 
-retry_transaction:
-    t = xs_transaction_start(ctx->xsh);
-    if (aodev->force)
-        libxl__xs_path_cleanup(gc, t,
-                               libxl__device_frontend_path(gc, aodev->dev));
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/online", be_path), "0", strlen("0"));
-    xs_write(ctx->xsh, t, state_path, "5", strlen("5"));
-    if (!xs_transaction_end(ctx->xsh, t, 0)) {
-        if (errno == EAGAIN)
-            goto retry_transaction;
-        else {
-            rc = ERROR_FAIL;
+    for (;;) {
+        rc = libxl__xs_transaction_start(gc, &t);
+        if (rc) {
+            LOG(ERROR, "unable to start transaction");
+            goto out;
+        }
+
+        rc = libxl__xs_read_checked(gc, t, state_path, &state);
+        if (rc) {
+            LOG(ERROR, "unable to read device state from path %s", state_path);
             goto out;
         }
+
+        if (aodev->force)
+            libxl__xs_path_cleanup(gc, t,
+                                   libxl__device_frontend_path(gc, aodev->dev));
+
+        /*
+         * Check if device is already in "closed" state, in which case
+         * it should not be changed.
+         */
+        if (atoi(state) != XenbusStateClosed) {
+            rc = libxl__xs_write_checked(gc, t, online_path, "0");
+            if (rc) {
+                LOG(ERROR, "unable to write to xenstore path %s", online_path);
+                goto out;
+            }
+            rc = libxl__xs_write_checked(gc, t, state_path, "5");
+            if (rc) {
+                LOG(ERROR, "unable to write to xenstore path %s", state_path);
+                goto out;
+            }
+        }
+
+        rc = libxl__xs_transaction_commit(gc, &t);
+        if (!rc) break;
+        if (rc < 0) goto out;
     }
-    /* mark transaction as ended, to prevent double closing it on out_ok */
-    t = 0;
 
     libxl__device_destroy_tapdisk(gc, be_path);
 
@@ -733,6 +755,7 @@ retry_transaction:
     return;
 
 out:
+    libxl__xs_transaction_abort(gc, &t);
     aodev->rc = rc;
     device_hotplug_done(egc, aodev);
     return;
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 6/9
#29 lore raw

Re: [PATCH 6/9] libxl: check backend state before setting it to "closing"

Roger Pau Monne writes ("[PATCH 6/9] libxl: check backend state before setting it to "closing""):

Quoted 2 lines

Check backend state before unconditionally setting it to "closing" (5), since it might already be in "closed" (6).

tools/libxl/libxl_device.c void libxl__initiate_device_remove(libxl__egc *egc, · line 732

Quoted 7 lines
tools/libxl/libxl_device.c +7 -0
+        if (atoi(state) != XenbusStateClosed) {
+            rc = libxl__xs_write_checked(gc, t, online_path, "0");
+            if (rc) {
+                LOG(ERROR, "unable to write to xenstore path %s", online_path);
+                goto out;
+            }
+            rc = libxl__xs_write_checked(gc, t, state_path, "5");

This business where we use XenbusStateClosed some of the time and "5", "6", etc. the rest of the time, is incredibly confusing. But now probably isn't the time to open that can of worms.

Ian.

#30 lore raw

PATCH 7/9 hotplug/NetBSD: check type of file to attach from params

In reply to Roger Pau Monne

xend used to set the xenbus backend entry "type" to either "phy" or "file", but now libxl sets it to "phy" for both file and block device. We have to manually check for the type of the "param" filed in order to detect if we are trying to attach a file or a block device.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
---
 tools/hotplug/NetBSD/block |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/hotplug/NetBSD/block +5 -1
index cf5ff3a..95acaa0 100644
@@ -19,8 +19,12 @@ error() {
 
 xpath=$1
 xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
 xparams=$(xenstore-read "$xpath/params")
+if [ -b $xparams ]; then
+	xtype="phy"
+else
+	xtype="file"
+fi
 
 case $xstatus in
 6)
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 7/9
#31 lore raw

Re: [PATCH 7/9] hotplug/NetBSD: check type of file to attach from params

Quoted 8 lines · Roger Pau Monne

xend used to set the xenbus backend entry "type" to either "phy" or "file", but now libxl sets it to "phy" for both file and block device. We have to manually check for the type of the "param" filed in order to detect if we are trying to attach a file or a block device.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
Quoted 22 lines
---
 tools/hotplug/NetBSD/block |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/hotplug/NetBSD/block +5 -1
index cf5ff3a..95acaa0 100644
@@ -19,8 +19,12 @@ error() {
 
 xpath=$1
 xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
 xparams=$(xenstore-read "$xpath/params")
+if [ -b $xparams ]; then
+	xtype="phy"
+else
+	xtype="file"
+fi
 
 case $xstatus in
 6)
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#32 lore raw

Re: [PATCH 7/9] hotplug/NetBSD: check type of file to attach from params

In reply to Roger Pau Monne

Roger Pau Monne writes ("[PATCH 7/9] hotplug/NetBSD: check type of file to attach from params"):

Quoted 4 lines

xend used to set the xenbus backend entry "type" to either "phy" or "file", but now libxl sets it to "phy" for both file and block device. We have to manually check for the type of the "param" filed in order to detect if we are trying to attach a file or a block device.

This sounds and looks plausible but what if the type is something else ?

Ian.

#33 lore raw

Re: [PATCH 7/9] hotplug/NetBSD: check type of file to attach from params

Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 7/9] hotplug/NetBSD: check type of file to attach from params"):

Quoted 4 lines

xend used to set the xenbus backend entry "type" to either "phy" or "file", but now libxl sets it to "phy" for both file and block device. We have to manually check for the type of the "param" filed in order to detect if we are trying to attach a file or a block device.

This sounds and looks plausible but what if the type is something else ?

According to the checks we perform in libxl, it can't be anything else, but it might be good to add an exit 1 if it's neither 'phy' nor 'file'.

#34 lore raw

PATCH 8/9 libxl: call hotplug scripts from xl for NetBSD

In reply to Roger Pau Monne

Add the missing NetBSD functions to call hotplug scripts, and disable xenbackendd if libxl/disable_udev is not set.

Cc Christoph Egger <[email protected]>
Cc Ian Jackson <[email protected]>
---
 tools/libxl/libxl_netbsd.c      |   57 ++++++++++++++++++++++++++++++++++++++-
 tools/xenbackendd/xenbackendd.c |    8 +++++-
 2 files changed, 63 insertions(+), 2 deletions(-)
tools/libxl/libxl_netbsd.c +56 -1
index 28cdf21..9587833 100644
@@ -32,10 +32,65 @@ char *libxl__devid_to_localdev(libxl__gc *gc, int devid)
 }
 
 /* Hotplug scripts caller functions */
+static int libxl__hotplug(libxl__gc *gc, libxl__device *dev, char ***args,
+                          libxl__device_action action)
+{
+    char *be_path = libxl__device_backend_path(gc, dev);
+    char *script;
+    int nr = 0, rc = 0, arraysize = 4;
+
+    script = libxl__xs_read(gc, XBT_NULL,
+                            GCSPRINTF("%s/%s", be_path, "script"));
+    if (!script) {
+        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    GCNEW_ARRAY(*args, arraysize);
+    (*args)[nr++] = script;
+    (*args)[nr++] = be_path;
+    (*args)[nr++] = GCSPRINTF("%d", action == DEVICE_CONNECT ?
+                                    XenbusStateInitWait : XenbusStateClosed);
+    (*args)[nr++] = NULL;
+    assert(nr == arraysize);
+
+out:
+    return rc;
+}
+
 int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                    char ***args, char ***env,
                                    libxl__device_action action,
                                    int num_exec)
 {
-    return 0;
+    char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
+    int rc;
+
+    /* Check if we have to run hotplug scripts */
+    if (!disable_udev || num_exec > 0) {
+        rc = 0;
+        goto out;
+    }
+
+    switch (dev->backend_kind) {
+    case LIBXL__DEVICE_KIND_VBD:
+    case LIBXL__DEVICE_KIND_VIF:
+        if (num_exec != 0) {
+            rc = 0;
+            goto out;
+        }
+        rc = libxl__hotplug(gc, dev, args, action);
+        if (!rc) rc = 1;
+        break;
+    default:
+        /* If no need to execute any hotplug scripts,
+         * call the callback manually
+         */
+        rc = 0;
+        break;
+    }
+
+out:
+    return rc;
 }
tools/xenbackendd/xenbackendd.c +7 -1
index 6b5bb8e..5381a2a 100644
@@ -33,6 +33,7 @@
 #define DEVTYPE_UNKNOWN 0
 #define DEVTYPE_VIF 1
 #define DEVTYPE_VBD 2
+#define DISABLE_EXEC "libxl/disable_udev"
 
 #define DOMAIN_PATH "/local/domain/0"
 
@@ -149,7 +150,7 @@ main(int argc, char * const argv[])
 	unsigned int num;
 	char *s;
 	int state;
-	char *sstate;
+	char *sstate, *sdisable;
 	char *p;
 	char buf[80];
 	int type;
@@ -245,6 +246,10 @@ main(int argc, char * const argv[])
 			continue;
 		}
 
+		sdisable = xs_read(xs, XBT_NULL, DISABLE_EXEC, 0);
+		if (sdisable)
+			goto next1;
+
 		if (strlen(vec[XS_WATCH_PATH]) < sizeof("state"))
 			goto next1;
 
@@ -314,6 +319,7 @@ next2:
 		free(sstate);
 
 next1:
+		free(sdisable);
 		free(vec);
 	}
 
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 8/9
#35 lore raw

Re: [PATCH 8/9] libxl: call hotplug scripts from xl for NetBSD

Roger Pau Monne writes ("[PATCH 8/9] libxl: call hotplug scripts from xl for NetBSD"):

Quoted 2 lines

Add the missing NetBSD functions to call hotplug scripts, and disable xenbackendd if libxl/disable_udev is not set.

I haven't checked this for correctness (knowing little about NetBSD) but it looks about right and doesn't touch non-BSD code.

Ian.

#36 lore raw

PATCH 9/9 init/NetBSD: move xenbackendd to xend init script

In reply to Roger Pau Monne

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
---
 tools/hotplug/NetBSD/rc.d/xencommons |   29 ++---------------
 tools/hotplug/NetBSD/rc.d/xend       |   57 +++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 29 deletions(-)
tools/hotplug/NetBSD/rc.d/xencommons +4 -25
index c0d87bf..fe4c9ac 100644
@@ -29,8 +29,6 @@ XENBACKENDD_PIDFILE="/var/run/xenbackendd.pid"
 
 xen_precmd()
 {
-	mkdir -p /var/run/xend || exit 1
-	mkdir -p /var/run/xend/boot || exit 1
 	mkdir -p /var/run/xenstored || exit 1
 }
 
@@ -46,7 +44,7 @@ xen_startcmd()
 			XENSTORED_ROOTDIR="/var/lib/xenstored"
 		fi
 		rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1
-		printf "Starting xenservices: xenstored, xenconsoled, xenbackendd."
+		printf "Starting xenservices: xenstored, xenconsoled."
 		XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
 		if [ -n "${XENSTORED_TRACE}" ]; then
 			XENSTORED_ARGS="${XENSTORED_ARGS} -T /var/log/xen/xenstored-trace.log"
@@ -58,7 +56,7 @@ xen_startcmd()
 			sleep 1
 		done
 	else
-		printf "Starting xenservices: xenconsoled, xenbackendd."
+		printf "Starting xenservices: xenconsoled."
 	fi
 
 	XENCONSOLED_ARGS=""
@@ -68,13 +66,6 @@ xen_startcmd()
 
 	${SBINDIR}/xenconsoled ${XENCONSOLED_ARGS}
 
-	XENBACKENDD_ARGS=""
-	if [ -n "${XENBACKENDD_DEBUG}" ]; then
-		XENBACKENDD_ARGS="${XENBACKENDD_ARGS} -d"
-	fi
-
-	${SBINDIR}/xenbackendd ${XENBACKENDD_ARGS}
-
 	printf "\n"
 
 	printf "Setting domain 0 name.\n"
@@ -87,8 +78,6 @@ xen_stop()
 	printf "Stopping xencommons.\n"
 	printf "WARNING: Not stopping xenstored, as it cannot be restarted.\n"
 
-	rc_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
-	pids="$pids $rc_pid"
 	rc_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${SBINDIR}/xenconsoled)
 	pids="$pids $rc_pid"
 
@@ -108,17 +97,12 @@ xen_status()
 		pids="$pids $xenconsoled_pid"
 	fi
 
-	xenbackend_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
-	if test -n ${xenbackend_pid}; then
-		pids="$pids $xenbackend_pid"
-	fi
-
-	if test -n "$xenbackend_pid" -a -n "$xenconsoled_pid" -a -n "$xenstored_pid";
+	if test -n "$xenconsoled_pid" -a -n "$xenstored_pid";
 	then
 		echo "xencommons are running as pids $pids."
 		return 0
 	fi
-	if test -z "$xenbackend_pid" -a -z "$xenconsoled_pid" -a -z "$xenstored_pid";
+	if test -z "$xenconsoled_pid" -a -z "$xenstored_pid";
 	then
 		echo "xencommons are not running."
 		return 0
@@ -134,11 +118,6 @@ xen_status()
 	else
 		echo "xenconsoled is not running."
 	fi
-	if test -n $xenbackend_pid; then
-		echo "xenbackendd is running as pid $xenbackend_pid."
-	else
-		echo "xenbackendd is not running."
-	fi
 }
 
 load_rc_config $name
tools/hotplug/NetBSD/rc.d/xend +53 -4

63 lines not on this page · raw message

Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 9/9
#37 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 6 lines · Roger Pau Monne

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

Cc Ian Jackson <[email protected]>
Cc Christoph Egger <[email protected]>
Quoted 159 lines
---
 tools/hotplug/NetBSD/rc.d/xencommons |   29 ++---------------
 tools/hotplug/NetBSD/rc.d/xend       |   57 +++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 29 deletions(-)
tools/hotplug/NetBSD/rc.d/xencommons +4 -25
index c0d87bf..fe4c9ac 100644
@@ -29,8 +29,6 @@ XENBACKENDD_PIDFILE="/var/run/xenbackendd.pid"
 
 xen_precmd()
 {
-	mkdir -p /var/run/xend || exit 1
-	mkdir -p /var/run/xend/boot || exit 1
 	mkdir -p /var/run/xenstored || exit 1
 }
 
@@ -46,7 +44,7 @@ xen_startcmd()
 			XENSTORED_ROOTDIR="/var/lib/xenstored"
 		fi
 		rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1
-		printf "Starting xenservices: xenstored, xenconsoled, xenbackendd."
+		printf "Starting xenservices: xenstored, xenconsoled."
 		XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
 		if [ -n "${XENSTORED_TRACE}" ]; then
 			XENSTORED_ARGS="${XENSTORED_ARGS} -T /var/log/xen/xenstored-trace.log"
@@ -58,7 +56,7 @@ xen_startcmd()
 			sleep 1
 		done
 	else
-		printf "Starting xenservices: xenconsoled, xenbackendd."
+		printf "Starting xenservices: xenconsoled."
 	fi
 
 	XENCONSOLED_ARGS=""
@@ -68,13 +66,6 @@ xen_startcmd()
 
 	${SBINDIR}/xenconsoled ${XENCONSOLED_ARGS}
 
-	XENBACKENDD_ARGS=""
-	if [ -n "${XENBACKENDD_DEBUG}" ]; then
-		XENBACKENDD_ARGS="${XENBACKENDD_ARGS} -d"
-	fi
-
-	${SBINDIR}/xenbackendd ${XENBACKENDD_ARGS}
-
 	printf "\n"
 
 	printf "Setting domain 0 name.\n"
@@ -87,8 +78,6 @@ xen_stop()
 	printf "Stopping xencommons.\n"
 	printf "WARNING: Not stopping xenstored, as it cannot be restarted.\n"
 
-	rc_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
-	pids="$pids $rc_pid"
 	rc_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${SBINDIR}/xenconsoled)
 	pids="$pids $rc_pid"
 
@@ -108,17 +97,12 @@ xen_status()
 		pids="$pids $xenconsoled_pid"
 	fi
 
-	xenbackend_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
-	if test -n ${xenbackend_pid}; then
-		pids="$pids $xenbackend_pid"
-	fi
-
-	if test -n "$xenbackend_pid" -a -n "$xenconsoled_pid" -a -n "$xenstored_pid";
+	if test -n "$xenconsoled_pid" -a -n "$xenstored_pid";
 	then
 		echo "xencommons are running as pids $pids."
 		return 0
 	fi
-	if test -z "$xenbackend_pid" -a -z "$xenconsoled_pid" -a -z "$xenstored_pid";
+	if test -z "$xenconsoled_pid" -a -z "$xenstored_pid";
 	then
 		echo "xencommons are not running."
 		return 0
@@ -134,11 +118,6 @@ xen_status()
 	else
 		echo "xenconsoled is not running."
 	fi
-	if test -n $xenbackend_pid; then
-		echo "xenbackendd is running as pid $xenbackend_pid."
-	else
-		echo "xenbackendd is not running."
-	fi
 }
 
 load_rc_config $name
tools/hotplug/NetBSD/rc.d/xend +53 -4
index ead9ee0..7fd9bc0 100644
@@ -15,10 +15,59 @@ export PATH
 
 name="xend"
 rcvar=$name
-command="${SBINDIR}/xend"
-command_args="start"
-command_interpreter=`head -n 1 ${command} | awk '{ print substr($0,3) }'`
-sig_stop="SIGKILL"
+start_precmd="xend_precmd"
+start_cmd="xend_startcmd"
+stop_cmd="xend_stop"
+status_cmd="xend_status"
+extra_commands="status"
+required_files="/kern/xen/privcmd"
+
+XENBACKENDD_PIDFILE="/var/run/xenbackendd.pid"
+#XENBACKENDD_DEBUG=1
+
+xend_precmd()
+{
+	mkdir -p /var/run/xend || exit 1
+	mkdir -p /var/run/xend/boot || exit 1
+}
+
+xend_startcmd()
+{
+	printf "Starting xenbackendd.\n"
+
+	XENBACKENDD_ARGS=""
+	if [ -n "${XENBACKENDD_DEBUG}" ]; then
+		XENBACKENDD_ARGS="${XENBACKENDD_ARGS} -d"
+	fi
+
+	${SBINDIR}/xenbackendd ${XENBACKENDD_ARGS}
+
+	printf "Starting xend.\n"
+	${SBINDIR}/xend start
+}
+
+xend_stop()
+{
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid
+	fi
+	if test -n "$xend_pid";
+	then
+		kill -${sig_stop:-KILL} $xend_pid
+	fi
+	wait_for_pids $xb_pid $xend_pid
+	rm -f /var/lock/subsys/xend /var/lock/xend /var/run/xenbackendd.pid
+}
+
+xend_status()
+{
+	${SBINDIR}/xend status
+}
 
 load_rc_config $name
 run_rc_command "$1"
+
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
Acked-by on v1 9/9
#38 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

In reply to Roger Pau Monne

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Ian.

#39 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

Quoted 9 lines

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

#40 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 19 lines · Roger Pau Monne
Quoted 8 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

Quoted 9 lines

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Quoted 4 lines

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

pkill xend should do it. :)

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#41 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 18 lines · Christoph Egger
Quoted 16 lines · Roger Pau Monne
Quoted 15 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Quoted 7 lines
Quoted 4 lines

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

pkill xend should do it. :)

Neither pgrep or pkill work, because the process command is registered as "/usr/pkg/bin/python2.7 /usr/xen42/sbin/xend start". I've tried:

pgrep /usr/xen42/sbin/xend
pgrep xend
pkill /usr/xen42/sbin/xend
pkill xend

And none of them work :(

#42 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 25 lines · Roger Pau Monne
Quoted 24 lines · Christoph Egger
Quoted 20 lines · Roger Pau Monne
Quoted 7 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

Quoted 8 lines

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

Quoted 4 lines
Quoted 1 line

pkill xend should do it. :)

Neither pgrep or pkill work, because the process command is registered as "/usr/pkg/bin/python2.7 /usr/xen42/sbin/xend start".

Oh, I see.

Quoted 10 lines

I've tried:

pgrep /usr/xen42/sbin/xend
pgrep xend
pkill /usr/xen42/sbin/xend
pkill xend

And none of them work :(

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#43 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

In reply to Roger Pau Monne
Quoted 29 lines · Roger Pau Monne
Quoted 18 lines · Christoph Egger
Quoted 16 lines · Roger Pau Monne
Quoted 15 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Quoted 6 lines
Quoted 4 lines

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

pkill xend should do it. :)

Neither pgrep or pkill work, because the process command is registered as "/usr/pkg/bin/python2.7 /usr/xen42/sbin/xend start". I've tried:

Quoted 6 lines

pgrep /usr/xen42/sbin/xend
pgrep xend
pkill /usr/xen42/sbin/xend
pkill xend

And none of them work :(

Now I got it, pgrep -f does the trick, thanks Christoph!

#44 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

In reply to Christoph Egger

Christoph Egger writes ("Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 7 lines · Roger Pau Monne
Quoted 4 lines

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

pkill xend should do it. :)

What if some other thing on the system has a process called `xend' ? Does it limit it to processes owned by root or something ?

Or is it just expected that on *BSD we will occasionally kill the wrong process ?

Ian.

#45 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

Quoted 6 lines · Ian Jackson

Christoph Egger writes ("Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 5 lines · Roger Pau Monne
Quoted 4 lines

Yes, but xend seems to spawn two processes that regenerate, so you have to kill them with one shot, or it will be useless. "xend stop" doesn't work either, but since xend is deprecated I think it's rather useless to try to fix this properly now.

Quoted 7 lines
Quoted 1 line

pkill xend should do it. :)

What if some other thing on the system has a process called `xend' ? Does it limit it to processes owned by root or something ?

Or is it just expected that on *BSD we will occasionally kill the wrong process ?

I'm using the full path (pkill -f /usr/xen42/sbin/xend), so unless another process has an argument that's /usr/xen42/sbin/xend (which I've never seen) it will only kill xend.

#46 lore raw

Re: [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

In reply to Ian Jackson
Quoted 9 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH 9/9] init/NetBSD: move xenbackendd to xend init script"):

Quoted 2 lines

xenbackendd is not needed by the xl toolstack, so move it's launch to the xend script.

on the basis that it doesn't touch non-BSD code. But:

Quoted 9 lines

tools/hotplug/NetBSD/rc.d/xend export PATH · line 56

Quoted 6 lines
tools/hotplug/NetBSD/rc.d/xend +6 -0
+	printf "Stopping xenbackendd, xend\n"
+	xb_pid=$(check_pidfile ${XENBACKENDD_PIDFILE} ${SBINDIR}/xenbackendd)
+	xend_pid=`ps x -o pid,command|grep ${SBINDIR}/xend|awk '{ print $1 }'`
+	if test -n "$xb_pid";
+	then
+		kill -${sig_stop:-TERM} $xb_pid

This is pretty horrid. Does BSD not have better ways to manage daemons ?

Does a

xend_pid=pgrep xend

work ?

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#47 lore raw
In reply to Roger Pau Monne
Quoted 6 lines · Roger Pau Monne

This series contains minor fixes to build xen on NetBSD and adds hotplug support to NetBSD. After this, xen-unstable should build and work out-of-the-box on NetBSD.

This fixes are not related, and as far as I know, can be applied sepparetedly:

I've applied:

Quoted 2 lines

[PATCH 1/9] xenstore: don't print an error when gntdev cannot be [PATCH 3/9] pygrub: don't leave fds open

The rest I skipped because they weren't yet acked. Apart from:

Quoted 1 line

[PATCH 6/9] libxl: check backend state before setting it to

Which I already applied from your V10 hotplug script series.

And:

Quoted 2 lines

[PATCH 8/9] libxl: call hotplug scripts from xl for NetBSD [PATCH 9/9] init/NetBSD: move xenbackendd to xend init script

which were Acked but didn't apply cleanly. I suspect conflicts with the parts of your hotplug series that I've just applied.

Ian.