protocol: expose discovery reinit over client/server protocol
authorJeremy Kerr <jk@ozlabs.org>
Wed, 2 Apr 2014 06:53:07 +0000 (14:53 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 2 Apr 2014 06:53:07 +0000 (14:53 +0800)
Now that we can re-initialise the device handler, allow this to be
triggered from UIs over the petitboot protocol.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
discover/device-handler.h
discover/discover-server.c
lib/pb-protocol/pb-protocol.h
ui/common/discover-client.c
ui/common/discover-client.h

index f5dc32c7abcb4f2239980b1c5a837fd2dd60cc2b..dd3aee92ca35d0385880b190f60a379494152ad8 100644 (file)
@@ -294,7 +294,7 @@ struct device_handler *device_handler_init(struct discover_server *server,
        return handler;
 }
 
-static void device_handler_reinit(struct device_handler *handler)
+void device_handler_reinit(struct device_handler *handler)
 {
        struct discover_boot_option *opt, *tmp;
        unsigned int i;
index bad7447cfbb2e9e71ee9a3bac3ff8861f800aa54..246abf94657600e9916b196ec6ab1e4e1ee8d484 100644 (file)
@@ -117,6 +117,7 @@ void device_handler_boot(struct device_handler *handler,
 void device_handler_cancel_default(struct device_handler *handler);
 void device_handler_update_config(struct device_handler *handler,
                struct config *config);
+void device_handler_reinit(struct device_handler *handler);
 
 int device_request_write(struct discover_device *dev, bool *release);
 void device_release_write(struct discover_device *dev, bool release);
index 1765074ecd675038ddc75bf3bc997f4951b925cb..80919fdf3da68088f20f7bca696efa1a5c39e6aa 100644 (file)
@@ -245,6 +245,10 @@ static int discover_server_process_message(void *arg)
                device_handler_cancel_default(client->server->device_handler);
                break;
 
+       case PB_PROTOCOL_ACTION_REINIT:
+               device_handler_reinit(client->server->device_handler);
+               break;
+
        case PB_PROTOCOL_ACTION_CONFIG:
                config = talloc_zero(client, struct config);
 
index 901bb9d11699f4e9eea7889d98db9c3a90ebefbe..d6f149c54e6789746491a70ae7e280af0b6134b8 100644 (file)
@@ -21,6 +21,7 @@ enum pb_protocol_action {
        PB_PROTOCOL_ACTION_CANCEL_DEFAULT       = 0x7,
        PB_PROTOCOL_ACTION_SYSTEM_INFO          = 0x8,
        PB_PROTOCOL_ACTION_CONFIG               = 0x9,
+       PB_PROTOCOL_ACTION_REINIT               = 0xa,
 };
 
 struct pb_protocol_message {
index 0e7da9d2cca4a6a9535d9dd601601307f771e67f..fbf70bae9cbbe56897e18dfd9c119d64637b3a1f 100644 (file)
@@ -333,6 +333,19 @@ int discover_client_cancel_default(struct discover_client *client)
        return pb_protocol_write_message(client->fd, message);
 }
 
+int discover_client_send_reinit(struct discover_client *client)
+{
+       struct pb_protocol_message *message;
+
+       message = pb_protocol_create_message(client,
+                       PB_PROTOCOL_ACTION_REINIT, 0);
+
+       if (!message)
+               return -1;
+
+       return pb_protocol_write_message(client->fd, message);
+}
+
 int discover_client_send_config(struct discover_client *client,
                struct config *config)
 {
index 68be8a52c3be81e5d8adf4a2177eb50d7602cb16..405bd243c5ee4dc1dfadd3fbf4fee6ef1cca6859 100644 (file)
@@ -76,6 +76,9 @@ int discover_client_boot(struct discover_client *client,
  */
 int discover_client_cancel_default(struct discover_client *client);
 
+/* Tell the discover server to reinitialise */
+int discover_client_send_reinit(struct discover_client *client);
+
 /* Send new configuration data to the discover server */
 int discover_client_send_config(struct discover_client *client,
                struct config *config);