001/* 002 * VM-Operator 003 * Copyright (C) 2023 Michael N. Lipp 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <https://www.gnu.org/licenses/>. 017 */ 018 019package org.jdrupes.vmoperator.runner.qemu.events; 020 021import org.jdrupes.vmoperator.runner.qemu.commands.QmpCommand; 022import org.jgrapes.core.Channel; 023import org.jgrapes.core.Components; 024import org.jgrapes.core.Event; 025 026/** 027 * An {@link Event} that causes some component to send a QMP 028 * command to the Qemu process. 029 */ 030public class MonitorCommand extends Event<Void> { 031 032 private final QmpCommand command; 033 034 /** 035 * Instantiates a new exec qmp command. 036 * 037 * @param command the command 038 */ 039 public MonitorCommand(QmpCommand command) { 040 this.command = command; 041 } 042 043 /** 044 * Gets the command. 045 * 046 * @return the command 047 */ 048 public QmpCommand command() { 049 return command; 050 } 051 052 @Override 053 public String toString() { 054 StringBuilder builder = new StringBuilder(); 055 builder.append(Components.objectName(this)) 056 .append(" [").append(command); 057 if (channels() != null) { 058 builder.append(", channels=").append(Channel.toString(channels())); 059 } 060 builder.append(']'); 061 return builder.toString(); 062 } 063}