machine-dbus.c revision a658cafa98ab55ea948c29bc87eb3945d515fb41
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <string.h>
#include "bus-util.h"
#include "machine.h"
static int property_get_id(
const char *path,
const char *interface,
const char *property,
void *userdata) {
int r;
assert(m);
if (r < 0)
return r;
return 1;
}
static int property_get_state(
const char *path,
const char *interface,
const char *property,
void *userdata) {
const char *state;
int r;
assert(m);
if (r < 0)
return r;
return 1;
}
int r;
assert(m);
r = machine_stop(m);
if (r < 0)
}
const char *swho;
int r;
assert(m);
if (r < 0)
else {
if (who < 0)
return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho);
}
return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo);
if (r < 0)
}
const sd_bus_vtable machine_vtable[] = {
};
int machine_object_find(sd_bus *bus, const char *path, const char *interface, void **found, void *userdata) {
_cleanup_free_ char *e = NULL;
const char *p;
assert(m);
if (!p)
return 0;
e = bus_path_unescape(p);
if (!e)
return -ENOMEM;
if (!machine)
return 0;
return 1;
}
char *machine_bus_path(Machine *m) {
_cleanup_free_ char *e = NULL;
assert(m);
e = bus_path_escape(m->name);
if (!e)
return NULL;
return strappend("/org/freedesktop/machine1/machine/", e);
}
_cleanup_free_ char *p = NULL;
assert(m);
p = machine_bus_path(m);
if (!p)
return -ENOMEM;
return sd_bus_emit_signal(
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"so", m->name, p);
}
_cleanup_free_ char *p = NULL;
assert(m);
if (!m->create_message)
return 0;
c = m->create_message;
m->create_message = NULL;
if (error)
/* Update the machine state file before we notify the client
* about the result. */
machine_save(m);
p = machine_bus_path(m);
if (!p)
return -ENOMEM;
}