Revision 0f51726a xen-all.c
b/xen-all.c | ||
---|---|---|
737 | 737 |
} |
738 | 738 |
} |
739 | 739 |
|
740 |
static int store_dev_info(int domid, CharDriverState *cs, const char *string) |
|
741 |
{ |
|
742 |
struct xs_handle *xs = NULL; |
|
743 |
char *path = NULL; |
|
744 |
char *newpath = NULL; |
|
745 |
char *pts = NULL; |
|
746 |
int ret = -1; |
|
747 |
|
|
748 |
/* Only continue if we're talking to a pty. */ |
|
749 |
if (strncmp(cs->filename, "pty:", 4)) { |
|
750 |
return 0; |
|
751 |
} |
|
752 |
pts = cs->filename + 4; |
|
753 |
|
|
754 |
/* We now have everything we need to set the xenstore entry. */ |
|
755 |
xs = xs_open(0); |
|
756 |
if (xs == NULL) { |
|
757 |
fprintf(stderr, "Could not contact XenStore\n"); |
|
758 |
goto out; |
|
759 |
} |
|
760 |
|
|
761 |
path = xs_get_domain_path(xs, domid); |
|
762 |
if (path == NULL) { |
|
763 |
fprintf(stderr, "xs_get_domain_path() error\n"); |
|
764 |
goto out; |
|
765 |
} |
|
766 |
newpath = realloc(path, (strlen(path) + strlen(string) + |
|
767 |
strlen("/tty") + 1)); |
|
768 |
if (newpath == NULL) { |
|
769 |
fprintf(stderr, "realloc error\n"); |
|
770 |
goto out; |
|
771 |
} |
|
772 |
path = newpath; |
|
773 |
|
|
774 |
strcat(path, string); |
|
775 |
strcat(path, "/tty"); |
|
776 |
if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) { |
|
777 |
fprintf(stderr, "xs_write for '%s' fail", string); |
|
778 |
goto out; |
|
779 |
} |
|
780 |
ret = 0; |
|
781 |
|
|
782 |
out: |
|
783 |
free(path); |
|
784 |
xs_close(xs); |
|
785 |
|
|
786 |
return ret; |
|
787 |
} |
|
788 |
|
|
789 |
void xenstore_store_pv_console_info(int i, CharDriverState *chr) |
|
790 |
{ |
|
791 |
if (i == 0) { |
|
792 |
store_dev_info(xen_domid, chr, "/console"); |
|
793 |
} else { |
|
794 |
char buf[32]; |
|
795 |
snprintf(buf, sizeof(buf), "/device/console/%d", i); |
|
796 |
store_dev_info(xen_domid, chr, buf); |
|
797 |
} |
|
798 |
} |
|
799 |
|
|
740 | 800 |
static void xenstore_record_dm_state(XenIOState *s, const char *state) |
741 | 801 |
{ |
742 | 802 |
char path[50]; |
Also available in: Unified diff