Skip to contentSkip to conversation

libxl/netbsd: check num_exec in hotplug function

PATCH Wei Liu 3 participants 4 messages Jul 4, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Wei Liu

author
#1 lore raw

Add back xen-devel. Please reply to all recipients in the future.

Quoted 34 lines · John Nemeth

On Jul 2, 12:35pm, Wei Liu wrote:
}
} This basically replicates the same logic in libxl_linux.c. Without this } libxl will loop indefinitely trying to execute hotplug script.

One minor change required (see below).

} Reported-by: John Nemeth <[email protected]>
} Signed-off-by: Wei Liu <[email protected]>
} ---
} tools/libxl/libxl_netbsd.c | 18 ++++++++++++++++++
} 1 file changed, 18 insertions(+)
}
} diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
} index 096c057..92d3c89 100644
} --- a/tools/libxl/libxl_netbsd.c
} +++ b/tools/libxl/libxl_netbsd.c
} @@ -68,7 +68,25 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, }
} switch (dev->backend_kind) {
} case LIBXL__DEVICE_KIND_VBD:
} + if (num_exec != 0) {

} +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} +            rc = 0;
} +            goto out;
} +        }
} +        rc = libxl__hotplug(gc, dev, args, action);
} +        if (!rc) rc = 1;
} +        break;
}      case LIBXL__DEVICE_KIND_VIF:
} +        /*
} +         * If domain has a stubdom we don't have to execute hotplug scripts
} +         * for emulated interfaces
} +         */
Quoted 7 lines

} + if ((num_exec > 1) ||

The function is called with num_exec set to 0 and 1, so this
should be:

           if ((num_exec != 0) ||

AIUI this is related to how network is setup because we would need to hotplug both the emulated nic in QEMU and the PV nic. Is this line causing problem for you?

Wei.

Quoted 8 lines
} +            (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
} +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} +            rc = 0;
} +            goto out;
} +        }
}          rc = libxl__hotplug(gc, dev, args, action);
}          if (!rc) rc = 1;
}          break;
Quoted 4 lines

} --
} 2.1.4
}
}-- End of excerpt from Wei Liu

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

author
#2 lore raw

Also CC Roger since he authored the original code.

Feel free to correct me misunderstanding on this issue.

Quoted 42 lines · Wei Liu

Add back xen-devel. Please reply to all recipients in the future.

Quoted 39 lines · John Nemeth

On Jul 2, 12:35pm, Wei Liu wrote:
}
} This basically replicates the same logic in libxl_linux.c. Without this } libxl will loop indefinitely trying to execute hotplug script.

One minor change required (see below).

} Reported-by: John Nemeth <[email protected]>
} Signed-off-by: Wei Liu <[email protected]>
} ---
} tools/libxl/libxl_netbsd.c | 18 ++++++++++++++++++
} 1 file changed, 18 insertions(+)
}
} diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
} index 096c057..92d3c89 100644
} --- a/tools/libxl/libxl_netbsd.c
} +++ b/tools/libxl/libxl_netbsd.c
} @@ -68,7 +68,25 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, }
} switch (dev->backend_kind) {
} case LIBXL__DEVICE_KIND_VBD:
} + if (num_exec != 0) {

} +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} +            rc = 0;
} +            goto out;
} +        }
} +        rc = libxl__hotplug(gc, dev, args, action);
} +        if (!rc) rc = 1;
} +        break;
}      case LIBXL__DEVICE_KIND_VIF:
} +        /*
} +         * If domain has a stubdom we don't have to execute hotplug scripts
} +         * for emulated interfaces
} +         */

} + if ((num_exec > 1) ||

The function is called with num_exec set to 0 and 1, so this
should be:

Quoted 21 lines
Quoted 2 lines
           if ((num_exec != 0) ||

AIUI this is related to how network is setup because we would need to hotplug both the emulated nic in QEMU and the PV nic. Is this line causing problem for you?

Wei.

Quoted 12 lines
} +            (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
} +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} +            rc = 0;
} +            goto out;
} +        }
}          rc = libxl__hotplug(gc, dev, args, action);
}          if (!rc) rc = 1;
}          break;

} --
} 2.1.4
}
}-- End of excerpt from Wei Liu

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

#3 lore raw

On Jul 4, 12:23pm, Wei Liu wrote:
}
} Also CC Roger since he authored the original code.
}
} Feel free to correct me misunderstanding on this issue. }
} On Mon, Jul 04, 2016 at 12:09:30PM +0100, Wei Liu wrote:
} > Add back xen-devel. Please reply to all recipients in the future.

Oops, I usually do (*checks header*; yep, good this time).

} > On Mon, Jul 04, 2016 at 01:11:04AM -0700, John Nemeth wrote:
} > > On Jul 2, 12:35pm, Wei Liu wrote:
} > > }
} > > } This basically replicates the same logic in libxl_linux.c. Without this } > > } libxl will loop indefinitely trying to execute hotplug script.
} > >
} > > One minor change required (see below).
} > >
} > > } Reported-by: John Nemeth <[email protected]>
} > > } Signed-off-by: Wei Liu <[email protected]>
} > > } ---
} > > } tools/libxl/libxl_netbsd.c | 18 ++++++++++++++++++
} > > } 1 file changed, 18 insertions(+)
} > > }
} > > } diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
} > > } index 096c057..92d3c89 100644
} > > } --- a/tools/libxl/libxl_netbsd.c
} > > } +++ b/tools/libxl/libxl_netbsd.c
} > > } @@ -68,7 +68,25 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, } > > }
} > > } switch (dev->backend_kind) {
} > > } case LIBXL__DEVICE_KIND_VBD:
} > > } + if (num_exec != 0) {

} > > } +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} > > } +            rc = 0;
} > > } +            goto out;
} > > } +        }
} > > } +        rc = libxl__hotplug(gc, dev, args, action);
} > > } +        if (!rc) rc = 1;
} > > } +        break;
} > > }      case LIBXL__DEVICE_KIND_VIF:
} > > } +        /*
} > > } +         * If domain has a stubdom we don't have to execute hotplug scripts
} > > } +         * for emulated interfaces
} > > } +         */

} > > } + if ((num_exec > 1) ||
} > >
} > > The function is called with num_exec set to 0 and 1, so this
} > > should be:
} > >
} > > if ((num_exec != 0) ||
} >
} > AIUI this is related to how network is setup because we would need to } > hotplug both the emulated nic in QEMU and the PV nic. Is this line } > causing problem for you?
} >
} > Wei.

Yes, when the script is called the second time, it fails when
trying to add the interface to the bridge and returns an error. This results in xl aborting the domU creation process and tearing it down. If the script is supposed to be called twice, then there needs to be some way to distinguish the calls and what is supposed to happen during each call so the script can be adjusted. The change above allowed me to bring up a domU and work with it (including network). However, I only tested a PV domU, not an HVM one, so QEMU wasn't involved.

} > > } +            (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
} > > } +            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
} > > } +            rc = 0;
} > > } +            goto out;
} > > } +        }
} > > }          rc = libxl__hotplug(gc, dev, args, action);
} > > }          if (!rc) rc = 1;
} > > }          break;

} > > } --
} > > } 2.1.4
} > > }
} > > }-- End of excerpt from Wei Liu
}-- End of excerpt from Wei Liu

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

#4 lore raw
Quoted 21 lines · John Nemeth

On Jul 4, 12:23pm, Wei Liu wrote:
} On Mon, Jul 04, 2016 at 12:09:30PM +0100, Wei Liu wrote:
} > On Mon, Jul 04, 2016 at 01:11:04AM -0700, John Nemeth wrote:
} > > On Jul 2, 12:35pm, Wei Liu wrote:
} > > } + /*

} > > } +         * If domain has a stubdom we don't have to execute hotplug scripts
} > > } +         * for emulated interfaces
} > > } +         */

} > > } + if ((num_exec > 1) ||
} > >
} > > The function is called with num_exec set to 0 and 1, so this
} > > should be:
} > >
} > > if ((num_exec != 0) ||
} >
} > AIUI this is related to how network is setup because we would need to } > hotplug both the emulated nic in QEMU and the PV nic. Is this line } > causing problem for you?
} >
} > Wei.

Quoted 9 lines

Yes, when the script is called the second time, it fails when
trying to add the interface to the bridge and returns an error. This results in xl aborting the domU creation process and tearing it down. If the script is supposed to be called twice, then there needs to be some way to distinguish the calls and what is supposed to happen during each call so the script can be adjusted. The change above allowed me to bring up a domU and work with it (including network). However, I only tested a PV domU, not an HVM one, so QEMU wasn't involved.

I've already replied to the other thread with the reason why this needs to be num_exec != 0 instead of num_exec > 1, and to avoid further confusion I would recommend Wei to add a comment here when the patch is updated, since this is a NetBSD-specific behavior that's not shared with other Dom0s:

http://lists.xenproject.org/archives/html/xen-devel/2016-07/msg00178.html

Roger.

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