Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 9a8db4a

Browse files
YadongQisysopenci
authored andcommitted
Allow more parameters for guest_pm mediation
Allow more parameters for guest_pm mediation Change socket path to tmp foler. Tracked-On: OAM-99882 Signed-off-by: Yadong Qi <yadong.qi@intel.com>
1 parent bca496f commit 9a8db4a

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

src/guest/start.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ static int run_thermal_mediation_daemon(char *path) {
377377
static int run_guest_timekeep(char *path, char *p, size_t size, char *pipe_name) {
378378
int cx = 0;
379379
const char *pipe = pipe_name ? pipe_name : "qmp-time-keep-pipe";
380-
char buffer[1024] = {0}, dirn[1024] = {0};
381-
strncpy(dirn, path, 1023);
382-
snprintf(buffer, 1023, "%s/%s", dirname(dirn), pipe);
380+
char buffer[1024] = {0};
381+
g_strstrip(path);
382+
snprintf(buffer, 1023, "/tmp/%s", pipe);
383383
fprintf(stderr, "Timekeep: %s %s\n", path, buffer);
384384
int ret = execute_cmd(path, buffer, strlen(buffer), 1);
385385
if (ret == 0) {
@@ -391,12 +391,23 @@ static int run_guest_timekeep(char *path, char *p, size_t size, char *pipe_name)
391391
static int run_guest_pm(char *path, char *p, size_t size, char *socket_name) {
392392
int cx = 0;
393393
const char *socket = socket_name ? socket_name : "qmp-pm-sock";
394-
char buffer[1024] = {0}, dirn[1024] = {0};
395-
snprintf(buffer, 1023, "%s/%s", dirname(dirn), socket);
396-
fprintf(stderr, "PM: %s %s\n", path, buffer);
397-
int ret = execute_cmd(path, buffer, strlen(buffer), 1);
394+
char sock_path[1024] = {0};
395+
char buffer[2048] = {0};
396+
gchar **cmd = NULL;
397+
398+
if (!path || !p)
399+
return 0;
400+
401+
g_strstrip(path);
402+
cmd = g_strsplit(path, " ", 2);
403+
404+
snprintf(sock_path, 1023, "/tmp/%s", socket);
405+
snprintf(buffer, 2047, "%s %s", sock_path, cmd[1]);
406+
407+
fprintf(stderr, "PM Control: %s %s\n", cmd[0], buffer);
408+
int ret = execute_cmd(cmd[0], buffer, strlen(buffer), 1);
398409
if (ret == 0) {
399-
cx = snprintf(p, size, " -qmp unix:%s,server,nowait -no-reboot", buffer);
410+
cx = snprintf(p, size, " -qmp unix:%s,server,nowait -no-reboot", sock_path);
400411
}
401412
return cx;
402413
}

0 commit comments

Comments
 (0)