path: root/discover/device-handler.c
diff options
authorJeremy Kerr <>2013-03-11 13:43:48 +0800
committerJeremy Kerr <>2013-04-16 11:41:46 +0800
commitbd06734362bb727b09b943688d9b69aa0a84590d (patch)
tree476072cae1d0d28b286928c5fba589bde4a2d9aa /discover/device-handler.c
parentb838cf777ed3d21b166f8daddd4b11fc75e07307 (diff)
protocol: Separate device add from boot-option add messages
We want to cater for situations where boot options may be discovered some time after we get notificiation about devices. For instance, discovering boot options from DHCP configuration parameters. In this case, we'll need to notify UIs of boot options appear some time after the device (and/or other boot options on the same device) has appeared. This change adds a new protocol message type, PB_PROTOCOL_ACTION_BOOT_OPTION_ADD. We also rename PB_PROTOCOL_ACTION_ADD to make it clear that it is just for devices. The discover server is updated to send boot option add events at device discover time, but we are now able to decouple this later. We also update the clients to handle the boot option add events separately. Signed-off-by: Jeremy Kerr <>
Diffstat (limited to 'discover/device-handler.c')
1 files changed, 12 insertions, 4 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 12bd5ae..ab27b51 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -275,6 +275,7 @@ static int handle_add_udev_event(struct device_handler *handler,
struct event *event)
struct discover_context *ctx;
+ struct boot_option *opt;
const char *devname;
int rc;
@@ -311,7 +312,10 @@ static int handle_add_udev_event(struct device_handler *handler,
/* add device to handler device array */
device_handler_add(handler, ctx->device);
- discover_server_notify_add(handler->server, ctx->device);
+ discover_server_notify_device_add(handler->server, ctx->device);
+ list_for_each_entry(&ctx->device->boot_options, opt, list)
+ discover_server_notify_boot_option_add(handler->server, opt);
return 0;
@@ -325,7 +329,7 @@ static int handle_remove_udev_event(struct device_handler *handler,
if (!ctx)
return 0;
- discover_server_notify_remove(handler->server, ctx->device);
+ discover_server_notify_device_remove(handler->server, ctx->device);
/* remove device from handler device array */
device_handler_remove(handler, ctx->device);
@@ -338,6 +342,7 @@ static int handle_remove_udev_event(struct device_handler *handler,
static int handle_add_user_event(struct device_handler *handler,
struct event *event)
+ struct boot_option *opt;
struct device *device;
@@ -352,7 +357,10 @@ static int handle_add_user_event(struct device_handler *handler,
parse_user_event(device, event);
- discover_server_notify_add(handler->server, device);
+ discover_server_notify_device_add(handler->server, device);
+ list_for_each_entry(&device->boot_options, opt, list)
+ discover_server_notify_boot_option_add(handler->server, opt);
/* add device to handler device array */
device_handler_add(handler, device);
@@ -372,7 +380,7 @@ static int handle_remove_user_event(struct device_handler *handler,
if (!device)
return 0;
- discover_server_notify_remove(handler->server, device);
+ discover_server_notify_device_remove(handler->server, device);
/* remove device from handler device array */
device_handler_remove(handler, device);
OpenPOWER on IntegriCloud